aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/adm1031.c325
1 files changed, 132 insertions, 193 deletions
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index b3e358c65d02..53210555441a 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.c
@@ -27,6 +27,7 @@
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/hwmon.h> 29#include <linux/hwmon.h>
30#include <linux/hwmon-sysfs.h>
30#include <linux/err.h> 31#include <linux/err.h>
31#include <linux/mutex.h> 32#include <linux/mutex.h>
32 33
@@ -245,17 +246,21 @@ get_fan_auto_nearest(struct adm1031_data *data,
245 return 0; 246 return 0;
246} 247}
247 248
248static ssize_t show_fan_auto_channel(struct device *dev, char *buf, int nr) 249static ssize_t show_fan_auto_channel(struct device *dev,
250 struct device_attribute *attr, char *buf)
249{ 251{
252 int nr = to_sensor_dev_attr(attr)->index;
250 struct adm1031_data *data = adm1031_update_device(dev); 253 struct adm1031_data *data = adm1031_update_device(dev);
251 return sprintf(buf, "%d\n", GET_FAN_AUTO_BITFIELD(data, nr)); 254 return sprintf(buf, "%d\n", GET_FAN_AUTO_BITFIELD(data, nr));
252} 255}
253 256
254static ssize_t 257static ssize_t
255set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr) 258set_fan_auto_channel(struct device *dev, struct device_attribute *attr,
259 const char *buf, size_t count)
256{ 260{
257 struct i2c_client *client = to_i2c_client(dev); 261 struct i2c_client *client = to_i2c_client(dev);
258 struct adm1031_data *data = i2c_get_clientdata(client); 262 struct adm1031_data *data = i2c_get_clientdata(client);
263 int nr = to_sensor_dev_attr(attr)->index;
259 int val = simple_strtol(buf, NULL, 10); 264 int val = simple_strtol(buf, NULL, 10);
260 u8 reg; 265 u8 reg;
261 int ret; 266 int ret;
@@ -294,41 +299,35 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
294 return count; 299 return count;
295} 300}
296 301
297#define fan_auto_channel_offset(offset) \ 302static SENSOR_DEVICE_ATTR(auto_fan1_channel, S_IRUGO | S_IWUSR,
298static ssize_t show_fan_auto_channel_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 303 show_fan_auto_channel, set_fan_auto_channel, 0);
299{ \ 304static SENSOR_DEVICE_ATTR(auto_fan2_channel, S_IRUGO | S_IWUSR,
300 return show_fan_auto_channel(dev, buf, offset - 1); \ 305 show_fan_auto_channel, set_fan_auto_channel, 1);
301} \
302static ssize_t set_fan_auto_channel_##offset (struct device *dev, struct device_attribute *attr, \
303 const char *buf, size_t count) \
304{ \
305 return set_fan_auto_channel(dev, buf, count, offset - 1); \
306} \
307static DEVICE_ATTR(auto_fan##offset##_channel, S_IRUGO | S_IWUSR, \
308 show_fan_auto_channel_##offset, \
309 set_fan_auto_channel_##offset)
310
311fan_auto_channel_offset(1);
312fan_auto_channel_offset(2);
313 306
314/* Auto Temps */ 307/* Auto Temps */
315static ssize_t show_auto_temp_off(struct device *dev, char *buf, int nr) 308static ssize_t show_auto_temp_off(struct device *dev,
309 struct device_attribute *attr, char *buf)
316{ 310{
311 int nr = to_sensor_dev_attr(attr)->index;
317 struct adm1031_data *data = adm1031_update_device(dev); 312 struct adm1031_data *data = adm1031_update_device(dev);
318 return sprintf(buf, "%d\n", 313 return sprintf(buf, "%d\n",
319 AUTO_TEMP_OFF_FROM_REG(data->auto_temp[nr])); 314 AUTO_TEMP_OFF_FROM_REG(data->auto_temp[nr]));
320} 315}
321static ssize_t show_auto_temp_min(struct device *dev, char *buf, int nr) 316static ssize_t show_auto_temp_min(struct device *dev,
317 struct device_attribute *attr, char *buf)
322{ 318{
319 int nr = to_sensor_dev_attr(attr)->index;
323 struct adm1031_data *data = adm1031_update_device(dev); 320 struct adm1031_data *data = adm1031_update_device(dev);
324 return sprintf(buf, "%d\n", 321 return sprintf(buf, "%d\n",
325 AUTO_TEMP_MIN_FROM_REG(data->auto_temp[nr])); 322 AUTO_TEMP_MIN_FROM_REG(data->auto_temp[nr]));
326} 323}
327static ssize_t 324static ssize_t
328set_auto_temp_min(struct device *dev, const char *buf, size_t count, int nr) 325set_auto_temp_min(struct device *dev, struct device_attribute *attr,
326 const char *buf, size_t count)
329{ 327{
330 struct i2c_client *client = to_i2c_client(dev); 328 struct i2c_client *client = to_i2c_client(dev);
331 struct adm1031_data *data = i2c_get_clientdata(client); 329 struct adm1031_data *data = i2c_get_clientdata(client);
330 int nr = to_sensor_dev_attr(attr)->index;
332 int val = simple_strtol(buf, NULL, 10); 331 int val = simple_strtol(buf, NULL, 10);
333 332
334 mutex_lock(&data->update_lock); 333 mutex_lock(&data->update_lock);
@@ -338,17 +337,21 @@ set_auto_temp_min(struct device *dev, const char *buf, size_t count, int nr)
338 mutex_unlock(&data->update_lock); 337 mutex_unlock(&data->update_lock);
339 return count; 338 return count;
340} 339}
341static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr) 340static ssize_t show_auto_temp_max(struct device *dev,
341 struct device_attribute *attr, char *buf)
342{ 342{
343 int nr = to_sensor_dev_attr(attr)->index;
343 struct adm1031_data *data = adm1031_update_device(dev); 344 struct adm1031_data *data = adm1031_update_device(dev);
344 return sprintf(buf, "%d\n", 345 return sprintf(buf, "%d\n",
345 AUTO_TEMP_MAX_FROM_REG(data->auto_temp[nr])); 346 AUTO_TEMP_MAX_FROM_REG(data->auto_temp[nr]));
346} 347}
347static ssize_t 348static ssize_t
348set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr) 349set_auto_temp_max(struct device *dev, struct device_attribute *attr,
350 const char *buf, size_t count)
349{ 351{
350 struct i2c_client *client = to_i2c_client(dev); 352 struct i2c_client *client = to_i2c_client(dev);
351 struct adm1031_data *data = i2c_get_clientdata(client); 353 struct adm1031_data *data = i2c_get_clientdata(client);
354 int nr = to_sensor_dev_attr(attr)->index;
352 int val = simple_strtol(buf, NULL, 10); 355 int val = simple_strtol(buf, NULL, 10);
353 356
354 mutex_lock(&data->update_lock); 357 mutex_lock(&data->update_lock);
@@ -359,51 +362,32 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr)
359 return count; 362 return count;
360} 363}
361 364
362#define auto_temp_reg(offset) \ 365#define auto_temp_reg(offset) \
363static ssize_t show_auto_temp_##offset##_off (struct device *dev, struct device_attribute *attr, char *buf) \ 366static SENSOR_DEVICE_ATTR(auto_temp##offset##_off, S_IRUGO, \
364{ \ 367 show_auto_temp_off, NULL, offset - 1); \
365 return show_auto_temp_off(dev, buf, offset - 1); \ 368static SENSOR_DEVICE_ATTR(auto_temp##offset##_min, S_IRUGO | S_IWUSR, \
366} \ 369 show_auto_temp_min, set_auto_temp_min, offset - 1); \
367static ssize_t show_auto_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 370static SENSOR_DEVICE_ATTR(auto_temp##offset##_max, S_IRUGO | S_IWUSR, \
368{ \ 371 show_auto_temp_max, set_auto_temp_max, offset - 1)
369 return show_auto_temp_min(dev, buf, offset - 1); \
370} \
371static ssize_t show_auto_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
372{ \
373 return show_auto_temp_max(dev, buf, offset - 1); \
374} \
375static ssize_t set_auto_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \
376 const char *buf, size_t count) \
377{ \
378 return set_auto_temp_min(dev, buf, count, offset - 1); \
379} \
380static ssize_t set_auto_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \
381 const char *buf, size_t count) \
382{ \
383 return set_auto_temp_max(dev, buf, count, offset - 1); \
384} \
385static DEVICE_ATTR(auto_temp##offset##_off, S_IRUGO, \
386 show_auto_temp_##offset##_off, NULL); \
387static DEVICE_ATTR(auto_temp##offset##_min, S_IRUGO | S_IWUSR, \
388 show_auto_temp_##offset##_min, set_auto_temp_##offset##_min);\
389static DEVICE_ATTR(auto_temp##offset##_max, S_IRUGO | S_IWUSR, \
390 show_auto_temp_##offset##_max, set_auto_temp_##offset##_max)
391 372
392auto_temp_reg(1); 373auto_temp_reg(1);
393auto_temp_reg(2); 374auto_temp_reg(2);
394auto_temp_reg(3); 375auto_temp_reg(3);
395 376
396/* pwm */ 377/* pwm */
397static ssize_t show_pwm(struct device *dev, char *buf, int nr) 378static ssize_t show_pwm(struct device *dev,
379 struct device_attribute *attr, char *buf)
398{ 380{
381 int nr = to_sensor_dev_attr(attr)->index;
399 struct adm1031_data *data = adm1031_update_device(dev); 382 struct adm1031_data *data = adm1031_update_device(dev);
400 return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr])); 383 return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr]));
401} 384}
402static ssize_t 385static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
403set_pwm(struct device *dev, const char *buf, size_t count, int nr) 386 const char *buf, size_t count)
404{ 387{
405 struct i2c_client *client = to_i2c_client(dev); 388 struct i2c_client *client = to_i2c_client(dev);
406 struct adm1031_data *data = i2c_get_clientdata(client); 389 struct adm1031_data *data = i2c_get_clientdata(client);
390 int nr = to_sensor_dev_attr(attr)->index;
407 int val = simple_strtol(buf, NULL, 10); 391 int val = simple_strtol(buf, NULL, 10);
408 int reg; 392 int reg;
409 393
@@ -423,21 +407,12 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
423 return count; 407 return count;
424} 408}
425 409
426#define pwm_reg(offset) \ 410static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 0);
427static ssize_t show_pwm_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 411static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 1);
428{ \ 412static SENSOR_DEVICE_ATTR(auto_fan1_min_pwm, S_IRUGO | S_IWUSR,
429 return show_pwm(dev, buf, offset - 1); \ 413 show_pwm, set_pwm, 0);
430} \ 414static SENSOR_DEVICE_ATTR(auto_fan2_min_pwm, S_IRUGO | S_IWUSR,
431static ssize_t set_pwm_##offset (struct device *dev, struct device_attribute *attr, \ 415 show_pwm, set_pwm, 1);
432 const char *buf, size_t count) \
433{ \
434 return set_pwm(dev, buf, count, offset - 1); \
435} \
436static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
437 show_pwm_##offset, set_pwm_##offset)
438
439pwm_reg(1);
440pwm_reg(2);
441 416
442/* Fans */ 417/* Fans */
443 418
@@ -484,8 +459,10 @@ static int trust_fan_readings(struct adm1031_data *data, int chan)
484} 459}
485 460
486 461
487static ssize_t show_fan(struct device *dev, char *buf, int nr) 462static ssize_t show_fan(struct device *dev,
463 struct device_attribute *attr, char *buf)
488{ 464{
465 int nr = to_sensor_dev_attr(attr)->index;
489 struct adm1031_data *data = adm1031_update_device(dev); 466 struct adm1031_data *data = adm1031_update_device(dev);
490 int value; 467 int value;
491 468
@@ -494,23 +471,28 @@ static ssize_t show_fan(struct device *dev, char *buf, int nr)
494 return sprintf(buf, "%d\n", value); 471 return sprintf(buf, "%d\n", value);
495} 472}
496 473
497static ssize_t show_fan_div(struct device *dev, char *buf, int nr) 474static ssize_t show_fan_div(struct device *dev,
475 struct device_attribute *attr, char *buf)
498{ 476{
477 int nr = to_sensor_dev_attr(attr)->index;
499 struct adm1031_data *data = adm1031_update_device(dev); 478 struct adm1031_data *data = adm1031_update_device(dev);
500 return sprintf(buf, "%d\n", FAN_DIV_FROM_REG(data->fan_div[nr])); 479 return sprintf(buf, "%d\n", FAN_DIV_FROM_REG(data->fan_div[nr]));
501} 480}
502static ssize_t show_fan_min(struct device *dev, char *buf, int nr) 481static ssize_t show_fan_min(struct device *dev,
482 struct device_attribute *attr, char *buf)
503{ 483{
484 int nr = to_sensor_dev_attr(attr)->index;
504 struct adm1031_data *data = adm1031_update_device(dev); 485 struct adm1031_data *data = adm1031_update_device(dev);
505 return sprintf(buf, "%d\n", 486 return sprintf(buf, "%d\n",
506 FAN_FROM_REG(data->fan_min[nr], 487 FAN_FROM_REG(data->fan_min[nr],
507 FAN_DIV_FROM_REG(data->fan_div[nr]))); 488 FAN_DIV_FROM_REG(data->fan_div[nr])));
508} 489}
509static ssize_t 490static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
510set_fan_min(struct device *dev, const char *buf, size_t count, int nr) 491 const char *buf, size_t count)
511{ 492{
512 struct i2c_client *client = to_i2c_client(dev); 493 struct i2c_client *client = to_i2c_client(dev);
513 struct adm1031_data *data = i2c_get_clientdata(client); 494 struct adm1031_data *data = i2c_get_clientdata(client);
495 int nr = to_sensor_dev_attr(attr)->index;
514 int val = simple_strtol(buf, NULL, 10); 496 int val = simple_strtol(buf, NULL, 10);
515 497
516 mutex_lock(&data->update_lock); 498 mutex_lock(&data->update_lock);
@@ -524,11 +506,12 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr)
524 mutex_unlock(&data->update_lock); 506 mutex_unlock(&data->update_lock);
525 return count; 507 return count;
526} 508}
527static ssize_t 509static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
528set_fan_div(struct device *dev, const char *buf, size_t count, int nr) 510 const char *buf, size_t count)
529{ 511{
530 struct i2c_client *client = to_i2c_client(dev); 512 struct i2c_client *client = to_i2c_client(dev);
531 struct adm1031_data *data = i2c_get_clientdata(client); 513 struct adm1031_data *data = i2c_get_clientdata(client);
514 int nr = to_sensor_dev_attr(attr)->index;
532 int val = simple_strtol(buf, NULL, 10); 515 int val = simple_strtol(buf, NULL, 10);
533 u8 tmp; 516 u8 tmp;
534 int old_div; 517 int old_div;
@@ -567,44 +550,22 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
567} 550}
568 551
569#define fan_offset(offset) \ 552#define fan_offset(offset) \
570static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 553static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
571{ \ 554 show_fan, NULL, offset - 1); \
572 return show_fan(dev, buf, offset - 1); \ 555static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
573} \ 556 show_fan_min, set_fan_min, offset - 1); \
574static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 557static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
575{ \ 558 show_fan_div, set_fan_div, offset - 1)
576 return show_fan_min(dev, buf, offset - 1); \
577} \
578static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \
579{ \
580 return show_fan_div(dev, buf, offset - 1); \
581} \
582static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \
583 const char *buf, size_t count) \
584{ \
585 return set_fan_min(dev, buf, count, offset - 1); \
586} \
587static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \
588 const char *buf, size_t count) \
589{ \
590 return set_fan_div(dev, buf, count, offset - 1); \
591} \
592static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, \
593 NULL); \
594static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
595 show_fan_##offset##_min, set_fan_##offset##_min); \
596static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
597 show_fan_##offset##_div, set_fan_##offset##_div); \
598static DEVICE_ATTR(auto_fan##offset##_min_pwm, S_IRUGO | S_IWUSR, \
599 show_pwm_##offset, set_pwm_##offset)
600 559
601fan_offset(1); 560fan_offset(1);
602fan_offset(2); 561fan_offset(2);
603 562
604 563
605/* Temps */ 564/* Temps */
606static ssize_t show_temp(struct device *dev, char *buf, int nr) 565static ssize_t show_temp(struct device *dev,
566 struct device_attribute *attr, char *buf)
607{ 567{
568 int nr = to_sensor_dev_attr(attr)->index;
608 struct adm1031_data *data = adm1031_update_device(dev); 569 struct adm1031_data *data = adm1031_update_device(dev);
609 int ext; 570 int ext;
610 ext = nr == 0 ? 571 ext = nr == 0 ?
@@ -612,26 +573,33 @@ static ssize_t show_temp(struct device *dev, char *buf, int nr)
612 (((data->ext_temp[nr] >> ((nr - 1) * 3)) & 7)); 573 (((data->ext_temp[nr] >> ((nr - 1) * 3)) & 7));
613 return sprintf(buf, "%d\n", TEMP_FROM_REG_EXT(data->temp[nr], ext)); 574 return sprintf(buf, "%d\n", TEMP_FROM_REG_EXT(data->temp[nr], ext));
614} 575}
615static ssize_t show_temp_min(struct device *dev, char *buf, int nr) 576static ssize_t show_temp_min(struct device *dev,
577 struct device_attribute *attr, char *buf)
616{ 578{
579 int nr = to_sensor_dev_attr(attr)->index;
617 struct adm1031_data *data = adm1031_update_device(dev); 580 struct adm1031_data *data = adm1031_update_device(dev);
618 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr])); 581 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr]));
619} 582}
620static ssize_t show_temp_max(struct device *dev, char *buf, int nr) 583static ssize_t show_temp_max(struct device *dev,
584 struct device_attribute *attr, char *buf)
621{ 585{
586 int nr = to_sensor_dev_attr(attr)->index;
622 struct adm1031_data *data = adm1031_update_device(dev); 587 struct adm1031_data *data = adm1031_update_device(dev);
623 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr])); 588 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr]));
624} 589}
625static ssize_t show_temp_crit(struct device *dev, char *buf, int nr) 590static ssize_t show_temp_crit(struct device *dev,
591 struct device_attribute *attr, char *buf)
626{ 592{
593 int nr = to_sensor_dev_attr(attr)->index;
627 struct adm1031_data *data = adm1031_update_device(dev); 594 struct adm1031_data *data = adm1031_update_device(dev);
628 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[nr])); 595 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[nr]));
629} 596}
630static ssize_t 597static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
631set_temp_min(struct device *dev, const char *buf, size_t count, int nr) 598 const char *buf, size_t count)
632{ 599{
633 struct i2c_client *client = to_i2c_client(dev); 600 struct i2c_client *client = to_i2c_client(dev);
634 struct adm1031_data *data = i2c_get_clientdata(client); 601 struct adm1031_data *data = i2c_get_clientdata(client);
602 int nr = to_sensor_dev_attr(attr)->index;
635 int val; 603 int val;
636 604
637 val = simple_strtol(buf, NULL, 10); 605 val = simple_strtol(buf, NULL, 10);
@@ -643,11 +611,12 @@ set_temp_min(struct device *dev, const char *buf, size_t count, int nr)
643 mutex_unlock(&data->update_lock); 611 mutex_unlock(&data->update_lock);
644 return count; 612 return count;
645} 613}
646static ssize_t 614static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
647set_temp_max(struct device *dev, const char *buf, size_t count, int nr) 615 const char *buf, size_t count)
648{ 616{
649 struct i2c_client *client = to_i2c_client(dev); 617 struct i2c_client *client = to_i2c_client(dev);
650 struct adm1031_data *data = i2c_get_clientdata(client); 618 struct adm1031_data *data = i2c_get_clientdata(client);
619 int nr = to_sensor_dev_attr(attr)->index;
651 int val; 620 int val;
652 621
653 val = simple_strtol(buf, NULL, 10); 622 val = simple_strtol(buf, NULL, 10);
@@ -659,11 +628,12 @@ set_temp_max(struct device *dev, const char *buf, size_t count, int nr)
659 mutex_unlock(&data->update_lock); 628 mutex_unlock(&data->update_lock);
660 return count; 629 return count;
661} 630}
662static ssize_t 631static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
663set_temp_crit(struct device *dev, const char *buf, size_t count, int nr) 632 const char *buf, size_t count)
664{ 633{
665 struct i2c_client *client = to_i2c_client(dev); 634 struct i2c_client *client = to_i2c_client(dev);
666 struct adm1031_data *data = i2c_get_clientdata(client); 635 struct adm1031_data *data = i2c_get_clientdata(client);
636 int nr = to_sensor_dev_attr(attr)->index;
667 int val; 637 int val;
668 638
669 val = simple_strtol(buf, NULL, 10); 639 val = simple_strtol(buf, NULL, 10);
@@ -676,46 +646,15 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr)
676 return count; 646 return count;
677} 647}
678 648
679#define temp_reg(offset) \ 649#define temp_reg(offset) \
680static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 650static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
681{ \ 651 show_temp, NULL, offset - 1); \
682 return show_temp(dev, buf, offset - 1); \ 652static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
683} \ 653 show_temp_min, set_temp_min, offset - 1); \
684static ssize_t show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 654static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
685{ \ 655 show_temp_max, set_temp_max, offset - 1); \
686 return show_temp_min(dev, buf, offset - 1); \ 656static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \
687} \ 657 show_temp_crit, set_temp_crit, offset - 1)
688static ssize_t show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \
689{ \
690 return show_temp_max(dev, buf, offset - 1); \
691} \
692static ssize_t show_temp_##offset##_crit (struct device *dev, struct device_attribute *attr, char *buf) \
693{ \
694 return show_temp_crit(dev, buf, offset - 1); \
695} \
696static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \
697 const char *buf, size_t count) \
698{ \
699 return set_temp_min(dev, buf, count, offset - 1); \
700} \
701static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \
702 const char *buf, size_t count) \
703{ \
704 return set_temp_max(dev, buf, count, offset - 1); \
705} \
706static ssize_t set_temp_##offset##_crit (struct device *dev, struct device_attribute *attr, \
707 const char *buf, size_t count) \
708{ \
709 return set_temp_crit(dev, buf, count, offset - 1); \
710} \
711static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, \
712 NULL); \
713static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
714 show_temp_##offset##_min, set_temp_##offset##_min); \
715static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
716 show_temp_##offset##_max, set_temp_##offset##_max); \
717static DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \
718 show_temp_##offset##_crit, set_temp_##offset##_crit)
719 658
720temp_reg(1); 659temp_reg(1);
721temp_reg(2); 660temp_reg(2);
@@ -739,29 +678,29 @@ static int adm1031_attach_adapter(struct i2c_adapter *adapter)
739} 678}
740 679
741static struct attribute *adm1031_attributes[] = { 680static struct attribute *adm1031_attributes[] = {
742 &dev_attr_fan1_input.attr, 681 &sensor_dev_attr_fan1_input.dev_attr.attr,
743 &dev_attr_fan1_div.attr, 682 &sensor_dev_attr_fan1_div.dev_attr.attr,
744 &dev_attr_fan1_min.attr, 683 &sensor_dev_attr_fan1_min.dev_attr.attr,
745 &dev_attr_pwm1.attr, 684 &sensor_dev_attr_pwm1.dev_attr.attr,
746 &dev_attr_auto_fan1_channel.attr, 685 &sensor_dev_attr_auto_fan1_channel.dev_attr.attr,
747 &dev_attr_temp1_input.attr, 686 &sensor_dev_attr_temp1_input.dev_attr.attr,
748 &dev_attr_temp1_min.attr, 687 &sensor_dev_attr_temp1_min.dev_attr.attr,
749 &dev_attr_temp1_max.attr, 688 &sensor_dev_attr_temp1_max.dev_attr.attr,
750 &dev_attr_temp1_crit.attr, 689 &sensor_dev_attr_temp1_crit.dev_attr.attr,
751 &dev_attr_temp2_input.attr, 690 &sensor_dev_attr_temp2_input.dev_attr.attr,
752 &dev_attr_temp2_min.attr, 691 &sensor_dev_attr_temp2_min.dev_attr.attr,
753 &dev_attr_temp2_max.attr, 692 &sensor_dev_attr_temp2_max.dev_attr.attr,
754 &dev_attr_temp2_crit.attr, 693 &sensor_dev_attr_temp2_crit.dev_attr.attr,
755 694
756 &dev_attr_auto_temp1_off.attr, 695 &sensor_dev_attr_auto_temp1_off.dev_attr.attr,
757 &dev_attr_auto_temp1_min.attr, 696 &sensor_dev_attr_auto_temp1_min.dev_attr.attr,
758 &dev_attr_auto_temp1_max.attr, 697 &sensor_dev_attr_auto_temp1_max.dev_attr.attr,
759 698
760 &dev_attr_auto_temp2_off.attr, 699 &sensor_dev_attr_auto_temp2_off.dev_attr.attr,
761 &dev_attr_auto_temp2_min.attr, 700 &sensor_dev_attr_auto_temp2_min.dev_attr.attr,
762 &dev_attr_auto_temp2_max.attr, 701 &sensor_dev_attr_auto_temp2_max.dev_attr.attr,
763 702
764 &dev_attr_auto_fan1_min_pwm.attr, 703 &sensor_dev_attr_auto_fan1_min_pwm.dev_attr.attr,
765 704
766 &dev_attr_alarms.attr, 705 &dev_attr_alarms.attr,
767 706
@@ -773,19 +712,19 @@ static const struct attribute_group adm1031_group = {
773}; 712};
774 713
775static struct attribute *adm1031_attributes_opt[] = { 714static struct attribute *adm1031_attributes_opt[] = {
776 &dev_attr_fan2_input.attr, 715 &sensor_dev_attr_fan2_input.dev_attr.attr,
777 &dev_attr_fan2_div.attr, 716 &sensor_dev_attr_fan2_div.dev_attr.attr,
778 &dev_attr_fan2_min.attr, 717 &sensor_dev_attr_fan2_min.dev_attr.attr,
779 &dev_attr_pwm2.attr, 718 &sensor_dev_attr_pwm2.dev_attr.attr,
780 &dev_attr_auto_fan2_channel.attr, 719 &sensor_dev_attr_auto_fan2_channel.dev_attr.attr,
781 &dev_attr_temp3_input.attr, 720 &sensor_dev_attr_temp3_input.dev_attr.attr,
782 &dev_attr_temp3_min.attr, 721 &sensor_dev_attr_temp3_min.dev_attr.attr,
783 &dev_attr_temp3_max.attr, 722 &sensor_dev_attr_temp3_max.dev_attr.attr,
784 &dev_attr_temp3_crit.attr, 723 &sensor_dev_attr_temp3_crit.dev_attr.attr,
785 &dev_attr_auto_temp3_off.attr, 724 &sensor_dev_attr_auto_temp3_off.dev_attr.attr,
786 &dev_attr_auto_temp3_min.attr, 725 &sensor_dev_attr_auto_temp3_min.dev_attr.attr,
787 &dev_attr_auto_temp3_max.attr, 726 &sensor_dev_attr_auto_temp3_max.dev_attr.attr,
788 &dev_attr_auto_fan2_min_pwm.attr, 727 &sensor_dev_attr_auto_fan2_min_pwm.dev_attr.attr,
789 NULL 728 NULL
790}; 729};
791 730