diff options
Diffstat (limited to 'drivers/hwmon/f71805f.c')
-rw-r--r-- | drivers/hwmon/f71805f.c | 275 |
1 files changed, 132 insertions, 143 deletions
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c index e029e0a94ecc..885465df6e6a 100644 --- a/drivers/hwmon/f71805f.c +++ b/drivers/hwmon/f71805f.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/hwmon.h> | 30 | #include <linux/hwmon.h> |
31 | #include <linux/hwmon-sysfs.h> | 31 | #include <linux/hwmon-sysfs.h> |
32 | #include <linux/err.h> | 32 | #include <linux/err.h> |
33 | #include <linux/mutex.h> | ||
33 | #include <asm/io.h> | 34 | #include <asm/io.h> |
34 | 35 | ||
35 | static struct platform_device *pdev; | 36 | static struct platform_device *pdev; |
@@ -131,10 +132,10 @@ static struct resource f71805f_resource __initdata = { | |||
131 | struct f71805f_data { | 132 | struct f71805f_data { |
132 | unsigned short addr; | 133 | unsigned short addr; |
133 | const char *name; | 134 | const char *name; |
134 | struct semaphore lock; | 135 | struct mutex lock; |
135 | struct class_device *class_dev; | 136 | struct class_device *class_dev; |
136 | 137 | ||
137 | struct semaphore update_lock; | 138 | struct mutex update_lock; |
138 | char valid; /* !=0 if following fields are valid */ | 139 | char valid; /* !=0 if following fields are valid */ |
139 | unsigned long last_updated; /* In jiffies */ | 140 | unsigned long last_updated; /* In jiffies */ |
140 | unsigned long last_limits; /* In jiffies */ | 141 | unsigned long last_limits; /* In jiffies */ |
@@ -224,20 +225,20 @@ static u8 f71805f_read8(struct f71805f_data *data, u8 reg) | |||
224 | { | 225 | { |
225 | u8 val; | 226 | u8 val; |
226 | 227 | ||
227 | down(&data->lock); | 228 | mutex_lock(&data->lock); |
228 | outb(reg, data->addr + ADDR_REG_OFFSET); | 229 | outb(reg, data->addr + ADDR_REG_OFFSET); |
229 | val = inb(data->addr + DATA_REG_OFFSET); | 230 | val = inb(data->addr + DATA_REG_OFFSET); |
230 | up(&data->lock); | 231 | mutex_unlock(&data->lock); |
231 | 232 | ||
232 | return val; | 233 | return val; |
233 | } | 234 | } |
234 | 235 | ||
235 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) | 236 | static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val) |
236 | { | 237 | { |
237 | down(&data->lock); | 238 | mutex_lock(&data->lock); |
238 | outb(reg, data->addr + ADDR_REG_OFFSET); | 239 | outb(reg, data->addr + ADDR_REG_OFFSET); |
239 | outb(val, data->addr + DATA_REG_OFFSET); | 240 | outb(val, data->addr + DATA_REG_OFFSET); |
240 | up(&data->lock); | 241 | mutex_unlock(&data->lock); |
241 | } | 242 | } |
242 | 243 | ||
243 | /* It is important to read the MSB first, because doing so latches the | 244 | /* It is important to read the MSB first, because doing so latches the |
@@ -246,24 +247,24 @@ static u16 f71805f_read16(struct f71805f_data *data, u8 reg) | |||
246 | { | 247 | { |
247 | u16 val; | 248 | u16 val; |
248 | 249 | ||
249 | down(&data->lock); | 250 | mutex_lock(&data->lock); |
250 | outb(reg, data->addr + ADDR_REG_OFFSET); | 251 | outb(reg, data->addr + ADDR_REG_OFFSET); |
251 | val = inb(data->addr + DATA_REG_OFFSET) << 8; | 252 | val = inb(data->addr + DATA_REG_OFFSET) << 8; |
252 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 253 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
253 | val |= inb(data->addr + DATA_REG_OFFSET); | 254 | val |= inb(data->addr + DATA_REG_OFFSET); |
254 | up(&data->lock); | 255 | mutex_unlock(&data->lock); |
255 | 256 | ||
256 | return val; | 257 | return val; |
257 | } | 258 | } |
258 | 259 | ||
259 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) | 260 | static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val) |
260 | { | 261 | { |
261 | down(&data->lock); | 262 | mutex_lock(&data->lock); |
262 | outb(reg, data->addr + ADDR_REG_OFFSET); | 263 | outb(reg, data->addr + ADDR_REG_OFFSET); |
263 | outb(val >> 8, data->addr + DATA_REG_OFFSET); | 264 | outb(val >> 8, data->addr + DATA_REG_OFFSET); |
264 | outb(++reg, data->addr + ADDR_REG_OFFSET); | 265 | outb(++reg, data->addr + ADDR_REG_OFFSET); |
265 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); | 266 | outb(val & 0xff, data->addr + DATA_REG_OFFSET); |
266 | up(&data->lock); | 267 | mutex_unlock(&data->lock); |
267 | } | 268 | } |
268 | 269 | ||
269 | static struct f71805f_data *f71805f_update_device(struct device *dev) | 270 | static struct f71805f_data *f71805f_update_device(struct device *dev) |
@@ -271,7 +272,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
271 | struct f71805f_data *data = dev_get_drvdata(dev); | 272 | struct f71805f_data *data = dev_get_drvdata(dev); |
272 | int nr; | 273 | int nr; |
273 | 274 | ||
274 | down(&data->update_lock); | 275 | mutex_lock(&data->update_lock); |
275 | 276 | ||
276 | /* Limit registers cache is refreshed after 60 seconds */ | 277 | /* Limit registers cache is refreshed after 60 seconds */ |
277 | if (time_after(jiffies, data->last_updated + 60 * HZ) | 278 | if (time_after(jiffies, data->last_updated + 60 * HZ) |
@@ -323,7 +324,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev) | |||
323 | data->valid = 1; | 324 | data->valid = 1; |
324 | } | 325 | } |
325 | 326 | ||
326 | up(&data->update_lock); | 327 | mutex_unlock(&data->update_lock); |
327 | 328 | ||
328 | return data; | 329 | return data; |
329 | } | 330 | } |
@@ -362,10 +363,10 @@ static ssize_t set_in0_max(struct device *dev, struct device_attribute | |||
362 | struct f71805f_data *data = dev_get_drvdata(dev); | 363 | struct f71805f_data *data = dev_get_drvdata(dev); |
363 | long val = simple_strtol(buf, NULL, 10); | 364 | long val = simple_strtol(buf, NULL, 10); |
364 | 365 | ||
365 | down(&data->update_lock); | 366 | mutex_lock(&data->update_lock); |
366 | data->in_high[0] = in0_to_reg(val); | 367 | data->in_high[0] = in0_to_reg(val); |
367 | f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); | 368 | f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]); |
368 | up(&data->update_lock); | 369 | mutex_unlock(&data->update_lock); |
369 | 370 | ||
370 | return count; | 371 | return count; |
371 | } | 372 | } |
@@ -376,18 +377,14 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute | |||
376 | struct f71805f_data *data = dev_get_drvdata(dev); | 377 | struct f71805f_data *data = dev_get_drvdata(dev); |
377 | long val = simple_strtol(buf, NULL, 10); | 378 | long val = simple_strtol(buf, NULL, 10); |
378 | 379 | ||
379 | down(&data->update_lock); | 380 | mutex_lock(&data->update_lock); |
380 | data->in_low[0] = in0_to_reg(val); | 381 | data->in_low[0] = in0_to_reg(val); |
381 | f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); | 382 | f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]); |
382 | up(&data->update_lock); | 383 | mutex_unlock(&data->update_lock); |
383 | 384 | ||
384 | return count; | 385 | return count; |
385 | } | 386 | } |
386 | 387 | ||
387 | static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL); | ||
388 | static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max); | ||
389 | static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min); | ||
390 | |||
391 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, | 388 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
392 | char *buf) | 389 | char *buf) |
393 | { | 390 | { |
@@ -426,10 +423,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute | |||
426 | int nr = attr->index; | 423 | int nr = attr->index; |
427 | long val = simple_strtol(buf, NULL, 10); | 424 | long val = simple_strtol(buf, NULL, 10); |
428 | 425 | ||
429 | down(&data->update_lock); | 426 | mutex_lock(&data->update_lock); |
430 | data->in_high[nr] = in_to_reg(val); | 427 | data->in_high[nr] = in_to_reg(val); |
431 | f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); | 428 | f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]); |
432 | up(&data->update_lock); | 429 | mutex_unlock(&data->update_lock); |
433 | 430 | ||
434 | return count; | 431 | return count; |
435 | } | 432 | } |
@@ -442,31 +439,14 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute | |||
442 | int nr = attr->index; | 439 | int nr = attr->index; |
443 | long val = simple_strtol(buf, NULL, 10); | 440 | long val = simple_strtol(buf, NULL, 10); |
444 | 441 | ||
445 | down(&data->update_lock); | 442 | mutex_lock(&data->update_lock); |
446 | data->in_low[nr] = in_to_reg(val); | 443 | data->in_low[nr] = in_to_reg(val); |
447 | f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); | 444 | f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]); |
448 | up(&data->update_lock); | 445 | mutex_unlock(&data->update_lock); |
449 | 446 | ||
450 | return count; | 447 | return count; |
451 | } | 448 | } |
452 | 449 | ||
453 | #define sysfs_in(offset) \ | ||
454 | static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ | ||
455 | show_in, NULL, offset); \ | ||
456 | static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ | ||
457 | show_in_max, set_in_max, offset); \ | ||
458 | static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ | ||
459 | show_in_min, set_in_min, offset) | ||
460 | |||
461 | sysfs_in(1); | ||
462 | sysfs_in(2); | ||
463 | sysfs_in(3); | ||
464 | sysfs_in(4); | ||
465 | sysfs_in(5); | ||
466 | sysfs_in(6); | ||
467 | sysfs_in(7); | ||
468 | sysfs_in(8); | ||
469 | |||
470 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, | 450 | static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
471 | char *buf) | 451 | char *buf) |
472 | { | 452 | { |
@@ -495,24 +475,14 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute | |||
495 | int nr = attr->index; | 475 | int nr = attr->index; |
496 | long val = simple_strtol(buf, NULL, 10); | 476 | long val = simple_strtol(buf, NULL, 10); |
497 | 477 | ||
498 | down(&data->update_lock); | 478 | mutex_lock(&data->update_lock); |
499 | data->fan_low[nr] = fan_to_reg(val); | 479 | data->fan_low[nr] = fan_to_reg(val); |
500 | f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); | 480 | f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]); |
501 | up(&data->update_lock); | 481 | mutex_unlock(&data->update_lock); |
502 | 482 | ||
503 | return count; | 483 | return count; |
504 | } | 484 | } |
505 | 485 | ||
506 | #define sysfs_fan(offset) \ | ||
507 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ | ||
508 | show_fan, NULL, offset - 1); \ | ||
509 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | ||
510 | show_fan_min, set_fan_min, offset - 1) | ||
511 | |||
512 | sysfs_fan(1); | ||
513 | sysfs_fan(2); | ||
514 | sysfs_fan(3); | ||
515 | |||
516 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, | 486 | static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
517 | char *buf) | 487 | char *buf) |
518 | { | 488 | { |
@@ -562,10 +532,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute | |||
562 | int nr = attr->index; | 532 | int nr = attr->index; |
563 | long val = simple_strtol(buf, NULL, 10); | 533 | long val = simple_strtol(buf, NULL, 10); |
564 | 534 | ||
565 | down(&data->update_lock); | 535 | mutex_lock(&data->update_lock); |
566 | data->temp_high[nr] = temp_to_reg(val); | 536 | data->temp_high[nr] = temp_to_reg(val); |
567 | f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); | 537 | f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]); |
568 | up(&data->update_lock); | 538 | mutex_unlock(&data->update_lock); |
569 | 539 | ||
570 | return count; | 540 | return count; |
571 | } | 541 | } |
@@ -578,28 +548,14 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute | |||
578 | int nr = attr->index; | 548 | int nr = attr->index; |
579 | long val = simple_strtol(buf, NULL, 10); | 549 | long val = simple_strtol(buf, NULL, 10); |
580 | 550 | ||
581 | down(&data->update_lock); | 551 | mutex_lock(&data->update_lock); |
582 | data->temp_hyst[nr] = temp_to_reg(val); | 552 | data->temp_hyst[nr] = temp_to_reg(val); |
583 | f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); | 553 | f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]); |
584 | up(&data->update_lock); | 554 | mutex_unlock(&data->update_lock); |
585 | 555 | ||
586 | return count; | 556 | return count; |
587 | } | 557 | } |
588 | 558 | ||
589 | #define sysfs_temp(offset) \ | ||
590 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ | ||
591 | show_temp, NULL, offset - 1); \ | ||
592 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | ||
593 | show_temp_max, set_temp_max, offset - 1); \ | ||
594 | static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ | ||
595 | show_temp_hyst, set_temp_hyst, offset - 1); \ | ||
596 | static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO, \ | ||
597 | show_temp_type, NULL, offset - 1) | ||
598 | |||
599 | sysfs_temp(1); | ||
600 | sysfs_temp(2); | ||
601 | sysfs_temp(3); | ||
602 | |||
603 | static ssize_t show_alarms_in(struct device *dev, struct device_attribute | 559 | static ssize_t show_alarms_in(struct device *dev, struct device_attribute |
604 | *devattr, char *buf) | 560 | *devattr, char *buf) |
605 | { | 561 | { |
@@ -625,10 +581,6 @@ static ssize_t show_alarms_temp(struct device *dev, struct device_attribute | |||
625 | return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07); | 581 | return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07); |
626 | } | 582 | } |
627 | 583 | ||
628 | static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL); | ||
629 | static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL); | ||
630 | static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL); | ||
631 | |||
632 | static ssize_t show_name(struct device *dev, struct device_attribute | 584 | static ssize_t show_name(struct device *dev, struct device_attribute |
633 | *devattr, char *buf) | 585 | *devattr, char *buf) |
634 | { | 586 | { |
@@ -637,7 +589,89 @@ static ssize_t show_name(struct device *dev, struct device_attribute | |||
637 | return sprintf(buf, "%s\n", data->name); | 589 | return sprintf(buf, "%s\n", data->name); |
638 | } | 590 | } |
639 | 591 | ||
640 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 592 | static struct device_attribute f71805f_dev_attr[] = { |
593 | __ATTR(in0_input, S_IRUGO, show_in0, NULL), | ||
594 | __ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max), | ||
595 | __ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min), | ||
596 | __ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL), | ||
597 | __ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL), | ||
598 | __ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL), | ||
599 | __ATTR(name, S_IRUGO, show_name, NULL), | ||
600 | }; | ||
601 | |||
602 | static struct sensor_device_attribute f71805f_sensor_attr[] = { | ||
603 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), | ||
604 | SENSOR_ATTR(in1_max, S_IRUGO | S_IWUSR, | ||
605 | show_in_max, set_in_max, 1), | ||
606 | SENSOR_ATTR(in1_min, S_IRUGO | S_IWUSR, | ||
607 | show_in_min, set_in_min, 1), | ||
608 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), | ||
609 | SENSOR_ATTR(in2_max, S_IRUGO | S_IWUSR, | ||
610 | show_in_max, set_in_max, 2), | ||
611 | SENSOR_ATTR(in2_min, S_IRUGO | S_IWUSR, | ||
612 | show_in_min, set_in_min, 2), | ||
613 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), | ||
614 | SENSOR_ATTR(in3_max, S_IRUGO | S_IWUSR, | ||
615 | show_in_max, set_in_max, 3), | ||
616 | SENSOR_ATTR(in3_min, S_IRUGO | S_IWUSR, | ||
617 | show_in_min, set_in_min, 3), | ||
618 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), | ||
619 | SENSOR_ATTR(in4_max, S_IRUGO | S_IWUSR, | ||
620 | show_in_max, set_in_max, 4), | ||
621 | SENSOR_ATTR(in4_min, S_IRUGO | S_IWUSR, | ||
622 | show_in_min, set_in_min, 4), | ||
623 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), | ||
624 | SENSOR_ATTR(in5_max, S_IRUGO | S_IWUSR, | ||
625 | show_in_max, set_in_max, 5), | ||
626 | SENSOR_ATTR(in5_min, S_IRUGO | S_IWUSR, | ||
627 | show_in_min, set_in_min, 5), | ||
628 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), | ||
629 | SENSOR_ATTR(in6_max, S_IRUGO | S_IWUSR, | ||
630 | show_in_max, set_in_max, 6), | ||
631 | SENSOR_ATTR(in6_min, S_IRUGO | S_IWUSR, | ||
632 | show_in_min, set_in_min, 6), | ||
633 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), | ||
634 | SENSOR_ATTR(in7_max, S_IRUGO | S_IWUSR, | ||
635 | show_in_max, set_in_max, 7), | ||
636 | SENSOR_ATTR(in7_min, S_IRUGO | S_IWUSR, | ||
637 | show_in_min, set_in_min, 7), | ||
638 | SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), | ||
639 | SENSOR_ATTR(in8_max, S_IRUGO | S_IWUSR, | ||
640 | show_in_max, set_in_max, 8), | ||
641 | SENSOR_ATTR(in8_min, S_IRUGO | S_IWUSR, | ||
642 | show_in_min, set_in_min, 8), | ||
643 | |||
644 | SENSOR_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0), | ||
645 | SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, | ||
646 | show_temp_max, set_temp_max, 0), | ||
647 | SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, | ||
648 | show_temp_hyst, set_temp_hyst, 0), | ||
649 | SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0), | ||
650 | SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1), | ||
651 | SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, | ||
652 | show_temp_max, set_temp_max, 1), | ||
653 | SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, | ||
654 | show_temp_hyst, set_temp_hyst, 1), | ||
655 | SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1), | ||
656 | SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2), | ||
657 | SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, | ||
658 | show_temp_max, set_temp_max, 2), | ||
659 | SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, | ||
660 | show_temp_hyst, set_temp_hyst, 2), | ||
661 | SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2), | ||
662 | }; | ||
663 | |||
664 | static struct sensor_device_attribute f71805f_fan_attr[] = { | ||
665 | SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), | ||
666 | SENSOR_ATTR(fan1_min, S_IRUGO | S_IWUSR, | ||
667 | show_fan_min, set_fan_min, 0), | ||
668 | SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), | ||
669 | SENSOR_ATTR(fan2_min, S_IRUGO | S_IWUSR, | ||
670 | show_fan_min, set_fan_min, 1), | ||
671 | SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), | ||
672 | SENSOR_ATTR(fan3_min, S_IRUGO | S_IWUSR, | ||
673 | show_fan_min, set_fan_min, 2), | ||
674 | }; | ||
641 | 675 | ||
642 | /* | 676 | /* |
643 | * Device registration and initialization | 677 | * Device registration and initialization |
@@ -668,7 +702,7 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
668 | { | 702 | { |
669 | struct f71805f_data *data; | 703 | struct f71805f_data *data; |
670 | struct resource *res; | 704 | struct resource *res; |
671 | int err; | 705 | int i, err; |
672 | 706 | ||
673 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { | 707 | if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { |
674 | err = -ENOMEM; | 708 | err = -ENOMEM; |
@@ -678,9 +712,9 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
678 | 712 | ||
679 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 713 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
680 | data->addr = res->start; | 714 | data->addr = res->start; |
681 | init_MUTEX(&data->lock); | 715 | mutex_init(&data->lock); |
682 | data->name = "f71805f"; | 716 | data->name = "f71805f"; |
683 | init_MUTEX(&data->update_lock); | 717 | mutex_init(&data->update_lock); |
684 | 718 | ||
685 | platform_set_drvdata(pdev, data); | 719 | platform_set_drvdata(pdev, data); |
686 | 720 | ||
@@ -695,76 +729,31 @@ static int __devinit f71805f_probe(struct platform_device *pdev) | |||
695 | f71805f_init_device(data); | 729 | f71805f_init_device(data); |
696 | 730 | ||
697 | /* Register sysfs interface files */ | 731 | /* Register sysfs interface files */ |
698 | device_create_file(&pdev->dev, &dev_attr_in0_input); | 732 | for (i = 0; i < ARRAY_SIZE(f71805f_dev_attr); i++) { |
699 | device_create_file(&pdev->dev, &dev_attr_in0_max); | 733 | err = device_create_file(&pdev->dev, &f71805f_dev_attr[i]); |
700 | device_create_file(&pdev->dev, &dev_attr_in0_min); | 734 | if (err) |
701 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_input.dev_attr); | 735 | goto exit_class; |
702 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_input.dev_attr); | ||
703 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_input.dev_attr); | ||
704 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_input.dev_attr); | ||
705 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_input.dev_attr); | ||
706 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_input.dev_attr); | ||
707 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_input.dev_attr); | ||
708 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_input.dev_attr); | ||
709 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_max.dev_attr); | ||
710 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_max.dev_attr); | ||
711 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_max.dev_attr); | ||
712 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_max.dev_attr); | ||
713 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_max.dev_attr); | ||
714 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_max.dev_attr); | ||
715 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_max.dev_attr); | ||
716 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_max.dev_attr); | ||
717 | device_create_file(&pdev->dev, &sensor_dev_attr_in1_min.dev_attr); | ||
718 | device_create_file(&pdev->dev, &sensor_dev_attr_in2_min.dev_attr); | ||
719 | device_create_file(&pdev->dev, &sensor_dev_attr_in3_min.dev_attr); | ||
720 | device_create_file(&pdev->dev, &sensor_dev_attr_in4_min.dev_attr); | ||
721 | device_create_file(&pdev->dev, &sensor_dev_attr_in5_min.dev_attr); | ||
722 | device_create_file(&pdev->dev, &sensor_dev_attr_in6_min.dev_attr); | ||
723 | device_create_file(&pdev->dev, &sensor_dev_attr_in7_min.dev_attr); | ||
724 | device_create_file(&pdev->dev, &sensor_dev_attr_in8_min.dev_attr); | ||
725 | if (data->fan_enabled & (1 << 0)) { | ||
726 | device_create_file(&pdev->dev, | ||
727 | &sensor_dev_attr_fan1_input.dev_attr); | ||
728 | device_create_file(&pdev->dev, | ||
729 | &sensor_dev_attr_fan1_min.dev_attr); | ||
730 | } | 736 | } |
731 | if (data->fan_enabled & (1 << 1)) { | 737 | for (i = 0; i < ARRAY_SIZE(f71805f_sensor_attr); i++) { |
732 | device_create_file(&pdev->dev, | 738 | err = device_create_file(&pdev->dev, |
733 | &sensor_dev_attr_fan2_input.dev_attr); | 739 | &f71805f_sensor_attr[i].dev_attr); |
734 | device_create_file(&pdev->dev, | 740 | if (err) |
735 | &sensor_dev_attr_fan2_min.dev_attr); | 741 | goto exit_class; |
736 | } | 742 | } |
737 | if (data->fan_enabled & (1 << 2)) { | 743 | for (i = 0; i < ARRAY_SIZE(f71805f_fan_attr); i++) { |
738 | device_create_file(&pdev->dev, | 744 | if (!(data->fan_enabled & (1 << (i / 2)))) |
739 | &sensor_dev_attr_fan3_input.dev_attr); | 745 | continue; |
740 | device_create_file(&pdev->dev, | 746 | err = device_create_file(&pdev->dev, |
741 | &sensor_dev_attr_fan3_min.dev_attr); | 747 | &f71805f_fan_attr[i].dev_attr); |
748 | if (err) | ||
749 | goto exit_class; | ||
742 | } | 750 | } |
743 | device_create_file(&pdev->dev, | ||
744 | &sensor_dev_attr_temp1_input.dev_attr); | ||
745 | device_create_file(&pdev->dev, | ||
746 | &sensor_dev_attr_temp2_input.dev_attr); | ||
747 | device_create_file(&pdev->dev, | ||
748 | &sensor_dev_attr_temp3_input.dev_attr); | ||
749 | device_create_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr); | ||
750 | device_create_file(&pdev->dev, &sensor_dev_attr_temp2_max.dev_attr); | ||
751 | device_create_file(&pdev->dev, &sensor_dev_attr_temp3_max.dev_attr); | ||
752 | device_create_file(&pdev->dev, | ||
753 | &sensor_dev_attr_temp1_max_hyst.dev_attr); | ||
754 | device_create_file(&pdev->dev, | ||
755 | &sensor_dev_attr_temp2_max_hyst.dev_attr); | ||
756 | device_create_file(&pdev->dev, | ||
757 | &sensor_dev_attr_temp3_max_hyst.dev_attr); | ||
758 | device_create_file(&pdev->dev, &sensor_dev_attr_temp1_type.dev_attr); | ||
759 | device_create_file(&pdev->dev, &sensor_dev_attr_temp2_type.dev_attr); | ||
760 | device_create_file(&pdev->dev, &sensor_dev_attr_temp3_type.dev_attr); | ||
761 | device_create_file(&pdev->dev, &dev_attr_alarms_in); | ||
762 | device_create_file(&pdev->dev, &dev_attr_alarms_fan); | ||
763 | device_create_file(&pdev->dev, &dev_attr_alarms_temp); | ||
764 | device_create_file(&pdev->dev, &dev_attr_name); | ||
765 | 751 | ||
766 | return 0; | 752 | return 0; |
767 | 753 | ||
754 | exit_class: | ||
755 | dev_err(&pdev->dev, "Sysfs interface creation failed\n"); | ||
756 | hwmon_device_unregister(data->class_dev); | ||
768 | exit_free: | 757 | exit_free: |
769 | kfree(data); | 758 | kfree(data); |
770 | exit: | 759 | exit: |