aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hwmon/f71805f.c187
1 files changed, 136 insertions, 51 deletions
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index 2309be5b1861..3e4da620e9c7 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -241,9 +241,11 @@ static inline long fan_from_reg(u16 reg)
241 241
242static inline u16 fan_to_reg(long rpm) 242static inline u16 fan_to_reg(long rpm)
243{ 243{
244 /* If the low limit is set below what the chip can measure, 244 /*
245 store the largest possible 12-bit value in the registers, 245 * If the low limit is set below what the chip can measure,
246 so that no alarm will ever trigger. */ 246 * store the largest possible 12-bit value in the registers,
247 * so that no alarm will ever trigger.
248 */
247 if (rpm < 367) 249 if (rpm < 367)
248 return 0xfff; 250 return 0xfff;
249 return 1500000 / rpm; 251 return 1500000 / rpm;
@@ -308,9 +310,11 @@ static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val)
308 outb(val, data->addr + DATA_REG_OFFSET); 310 outb(val, data->addr + DATA_REG_OFFSET);
309} 311}
310 312
311/* It is important to read the MSB first, because doing so latches the 313/*
312 value of the LSB, so we are sure both bytes belong to the same value. 314 * It is important to read the MSB first, because doing so latches the
313 Must be called with data->update_lock held, except during initialization */ 315 * value of the LSB, so we are sure both bytes belong to the same value.
316 * Must be called with data->update_lock held, except during initialization
317 */
314static u16 f71805f_read16(struct f71805f_data *data, u8 reg) 318static u16 f71805f_read16(struct f71805f_data *data, u8 reg)
315{ 319{
316 u16 val; 320 u16 val;
@@ -455,7 +459,12 @@ static ssize_t set_in0_max(struct device *dev, struct device_attribute
455 struct f71805f_data *data = dev_get_drvdata(dev); 459 struct f71805f_data *data = dev_get_drvdata(dev);
456 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 460 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
457 int nr = attr->index; 461 int nr = attr->index;
458 long val = simple_strtol(buf, NULL, 10); 462 long val;
463 int err;
464
465 err = kstrtol(buf, 10, &val);
466 if (err)
467 return err;
459 468
460 mutex_lock(&data->update_lock); 469 mutex_lock(&data->update_lock);
461 data->in_high[nr] = in0_to_reg(val); 470 data->in_high[nr] = in0_to_reg(val);
@@ -471,7 +480,12 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute
471 struct f71805f_data *data = dev_get_drvdata(dev); 480 struct f71805f_data *data = dev_get_drvdata(dev);
472 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 481 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
473 int nr = attr->index; 482 int nr = attr->index;
474 long val = simple_strtol(buf, NULL, 10); 483 long val;
484 int err;
485
486 err = kstrtol(buf, 10, &val);
487 if (err)
488 return err;
475 489
476 mutex_lock(&data->update_lock); 490 mutex_lock(&data->update_lock);
477 data->in_low[nr] = in0_to_reg(val); 491 data->in_low[nr] = in0_to_reg(val);
@@ -517,7 +531,12 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute
517 struct f71805f_data *data = dev_get_drvdata(dev); 531 struct f71805f_data *data = dev_get_drvdata(dev);
518 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 532 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
519 int nr = attr->index; 533 int nr = attr->index;
520 long val = simple_strtol(buf, NULL, 10); 534 long val;
535 int err;
536
537 err = kstrtol(buf, 10, &val);
538 if (err)
539 return err;
521 540
522 mutex_lock(&data->update_lock); 541 mutex_lock(&data->update_lock);
523 data->in_high[nr] = in_to_reg(val); 542 data->in_high[nr] = in_to_reg(val);
@@ -533,7 +552,12 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute
533 struct f71805f_data *data = dev_get_drvdata(dev); 552 struct f71805f_data *data = dev_get_drvdata(dev);
534 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 553 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
535 int nr = attr->index; 554 int nr = attr->index;
536 long val = simple_strtol(buf, NULL, 10); 555 long val;
556 int err;
557
558 err = kstrtol(buf, 10, &val);
559 if (err)
560 return err;
537 561
538 mutex_lock(&data->update_lock); 562 mutex_lock(&data->update_lock);
539 data->in_low[nr] = in_to_reg(val); 563 data->in_low[nr] = in_to_reg(val);
@@ -579,7 +603,12 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute
579 struct f71805f_data *data = dev_get_drvdata(dev); 603 struct f71805f_data *data = dev_get_drvdata(dev);
580 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 604 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
581 int nr = attr->index; 605 int nr = attr->index;
582 long val = simple_strtol(buf, NULL, 10); 606 long val;
607 int err;
608
609 err = kstrtol(buf, 10, &val);
610 if (err)
611 return err;
583 612
584 mutex_lock(&data->update_lock); 613 mutex_lock(&data->update_lock);
585 data->fan_low[nr] = fan_to_reg(val); 614 data->fan_low[nr] = fan_to_reg(val);
@@ -595,7 +624,12 @@ static ssize_t set_fan_target(struct device *dev, struct device_attribute
595 struct f71805f_data *data = dev_get_drvdata(dev); 624 struct f71805f_data *data = dev_get_drvdata(dev);
596 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 625 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
597 int nr = attr->index; 626 int nr = attr->index;
598 long val = simple_strtol(buf, NULL, 10); 627 long val;
628 int err;
629
630 err = kstrtol(buf, 10, &val);
631 if (err)
632 return err;
599 633
600 mutex_lock(&data->update_lock); 634 mutex_lock(&data->update_lock);
601 data->fan_target[nr] = fan_to_reg(val); 635 data->fan_target[nr] = fan_to_reg(val);
@@ -664,7 +698,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr,
664 struct f71805f_data *data = dev_get_drvdata(dev); 698 struct f71805f_data *data = dev_get_drvdata(dev);
665 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 699 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
666 int nr = attr->index; 700 int nr = attr->index;
667 unsigned long val = simple_strtoul(buf, NULL, 10); 701 unsigned long val;
702 int err;
703
704 err = kstrtoul(buf, 10, &val);
705 if (err)
706 return err;
668 707
669 if (val > 255) 708 if (val > 255)
670 return -EINVAL; 709 return -EINVAL;
@@ -685,8 +724,13 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute
685 struct f71805f_data *data = dev_get_drvdata(dev); 724 struct f71805f_data *data = dev_get_drvdata(dev);
686 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 725 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
687 int nr = attr->index; 726 int nr = attr->index;
688 unsigned long val = simple_strtoul(buf, NULL, 10);
689 u8 reg; 727 u8 reg;
728 unsigned long val;
729 int err;
730
731 err = kstrtoul(buf, 10, &val);
732 if (err)
733 return err;
690 734
691 if (val < 1 || val > 3) 735 if (val < 1 || val > 3)
692 return -EINVAL; 736 return -EINVAL;
@@ -730,7 +774,12 @@ static ssize_t set_pwm_freq(struct device *dev, struct device_attribute
730 struct f71805f_data *data = dev_get_drvdata(dev); 774 struct f71805f_data *data = dev_get_drvdata(dev);
731 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 775 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
732 int nr = attr->index; 776 int nr = attr->index;
733 unsigned long val = simple_strtoul(buf, NULL, 10); 777 unsigned long val;
778 int err;
779
780 err = kstrtoul(buf, 10, &val);
781 if (err)
782 return err;
734 783
735 mutex_lock(&data->update_lock); 784 mutex_lock(&data->update_lock);
736 data->pwm_freq[nr] = pwm_freq_to_reg(val); 785 data->pwm_freq[nr] = pwm_freq_to_reg(val);
@@ -742,7 +791,7 @@ static ssize_t set_pwm_freq(struct device *dev, struct device_attribute
742 791
743static ssize_t show_pwm_auto_point_temp(struct device *dev, 792static ssize_t show_pwm_auto_point_temp(struct device *dev,
744 struct device_attribute *devattr, 793 struct device_attribute *devattr,
745 char* buf) 794 char *buf)
746{ 795{
747 struct f71805f_data *data = dev_get_drvdata(dev); 796 struct f71805f_data *data = dev_get_drvdata(dev);
748 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); 797 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
@@ -755,13 +804,18 @@ static ssize_t show_pwm_auto_point_temp(struct device *dev,
755 804
756static ssize_t set_pwm_auto_point_temp(struct device *dev, 805static ssize_t set_pwm_auto_point_temp(struct device *dev,
757 struct device_attribute *devattr, 806 struct device_attribute *devattr,
758 const char* buf, size_t count) 807 const char *buf, size_t count)
759{ 808{
760 struct f71805f_data *data = dev_get_drvdata(dev); 809 struct f71805f_data *data = dev_get_drvdata(dev);
761 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); 810 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
762 int pwmnr = attr->nr; 811 int pwmnr = attr->nr;
763 int apnr = attr->index; 812 int apnr = attr->index;
764 unsigned long val = simple_strtol(buf, NULL, 10); 813 unsigned long val;
814 int err;
815
816 err = kstrtoul(buf, 10, &val);
817 if (err)
818 return err;
765 819
766 mutex_lock(&data->update_lock); 820 mutex_lock(&data->update_lock);
767 data->auto_points[pwmnr].temp[apnr] = temp_to_reg(val); 821 data->auto_points[pwmnr].temp[apnr] = temp_to_reg(val);
@@ -774,7 +828,7 @@ static ssize_t set_pwm_auto_point_temp(struct device *dev,
774 828
775static ssize_t show_pwm_auto_point_fan(struct device *dev, 829static ssize_t show_pwm_auto_point_fan(struct device *dev,
776 struct device_attribute *devattr, 830 struct device_attribute *devattr,
777 char* buf) 831 char *buf)
778{ 832{
779 struct f71805f_data *data = dev_get_drvdata(dev); 833 struct f71805f_data *data = dev_get_drvdata(dev);
780 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); 834 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
@@ -787,18 +841,23 @@ static ssize_t show_pwm_auto_point_fan(struct device *dev,
787 841
788static ssize_t set_pwm_auto_point_fan(struct device *dev, 842static ssize_t set_pwm_auto_point_fan(struct device *dev,
789 struct device_attribute *devattr, 843 struct device_attribute *devattr,
790 const char* buf, size_t count) 844 const char *buf, size_t count)
791{ 845{
792 struct f71805f_data *data = dev_get_drvdata(dev); 846 struct f71805f_data *data = dev_get_drvdata(dev);
793 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr); 847 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
794 int pwmnr = attr->nr; 848 int pwmnr = attr->nr;
795 int apnr = attr->index; 849 int apnr = attr->index;
796 unsigned long val = simple_strtoul(buf, NULL, 10); 850 unsigned long val;
851 int err;
852
853 err = kstrtoul(buf, 10, &val);
854 if (err)
855 return err;
797 856
798 mutex_lock(&data->update_lock); 857 mutex_lock(&data->update_lock);
799 data->auto_points[pwmnr].fan[apnr] = fan_to_reg(val); 858 data->auto_points[pwmnr].fan[apnr] = fan_to_reg(val);
800 f71805f_write16(data, F71805F_REG_PWM_AUTO_POINT_FAN(pwmnr, apnr), 859 f71805f_write16(data, F71805F_REG_PWM_AUTO_POINT_FAN(pwmnr, apnr),
801 data->auto_points[pwmnr].fan[apnr]); 860 data->auto_points[pwmnr].fan[apnr]);
802 mutex_unlock(&data->update_lock); 861 mutex_unlock(&data->update_lock);
803 862
804 return count; 863 return count;
@@ -851,7 +910,12 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute
851 struct f71805f_data *data = dev_get_drvdata(dev); 910 struct f71805f_data *data = dev_get_drvdata(dev);
852 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 911 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
853 int nr = attr->index; 912 int nr = attr->index;
854 long val = simple_strtol(buf, NULL, 10); 913 long val;
914 int err;
915
916 err = kstrtol(buf, 10, &val);
917 if (err)
918 return err;
855 919
856 mutex_lock(&data->update_lock); 920 mutex_lock(&data->update_lock);
857 data->temp_high[nr] = temp_to_reg(val); 921 data->temp_high[nr] = temp_to_reg(val);
@@ -867,7 +931,12 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute
867 struct f71805f_data *data = dev_get_drvdata(dev); 931 struct f71805f_data *data = dev_get_drvdata(dev);
868 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 932 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
869 int nr = attr->index; 933 int nr = attr->index;
870 long val = simple_strtol(buf, NULL, 10); 934 long val;
935 int err;
936
937 err = kstrtol(buf, 10, &val);
938 if (err)
939 return err;
871 940
872 mutex_lock(&data->update_lock); 941 mutex_lock(&data->update_lock);
873 data->temp_hyst[nr] = temp_to_reg(val); 942 data->temp_hyst[nr] = temp_to_reg(val);
@@ -920,9 +989,9 @@ static ssize_t show_name(struct device *dev, struct device_attribute
920} 989}
921 990
922static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL, 0); 991static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL, 0);
923static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, 992static SENSOR_DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR,
924 show_in0_max, set_in0_max, 0); 993 show_in0_max, set_in0_max, 0);
925static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, 994static SENSOR_DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR,
926 show_in0_min, set_in0_min, 0); 995 show_in0_min, set_in0_min, 0);
927static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1); 996static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1);
928static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR, 997static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO | S_IWUSR,
@@ -1010,8 +1079,10 @@ static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR,
1010 show_temp_hyst, set_temp_hyst, 2); 1079 show_temp_hyst, set_temp_hyst, 2);
1011static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2); 1080static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2);
1012 1081
1013/* pwm (value) files are created read-only, write permission is 1082/*
1014 then added or removed dynamically as needed */ 1083 * pwm (value) files are created read-only, write permission is
1084 * then added or removed dynamically as needed
1085 */
1015static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO, show_pwm, set_pwm, 0); 1086static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO, show_pwm, set_pwm, 0);
1016static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, 1087static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
1017 show_pwm_enable, set_pwm_enable, 0); 1088 show_pwm_enable, set_pwm_enable, 0);
@@ -1246,8 +1317,10 @@ static const struct attribute_group f71805f_group_optin[4] = {
1246 { .attrs = f71805f_attributes_optin[3] }, 1317 { .attrs = f71805f_attributes_optin[3] },
1247}; 1318};
1248 1319
1249/* We don't include pwm_freq files in the arrays above, because they must be 1320/*
1250 created conditionally (only if pwm_mode is 1 == PWM) */ 1321 * We don't include pwm_freq files in the arrays above, because they must be
1322 * created conditionally (only if pwm_mode is 1 == PWM)
1323 */
1251static struct attribute *f71805f_attributes_pwm_freq[] = { 1324static struct attribute *f71805f_attributes_pwm_freq[] = {
1252 &sensor_dev_attr_pwm1_freq.dev_attr.attr, 1325 &sensor_dev_attr_pwm1_freq.dev_attr.attr,
1253 &sensor_dev_attr_pwm2_freq.dev_attr.attr, 1326 &sensor_dev_attr_pwm2_freq.dev_attr.attr,
@@ -1282,13 +1355,17 @@ static void __devinit f71805f_init_device(struct f71805f_data *data)
1282 f71805f_write8(data, F71805F_REG_START, (reg | 0x01) & ~0x40); 1355 f71805f_write8(data, F71805F_REG_START, (reg | 0x01) & ~0x40);
1283 } 1356 }
1284 1357
1285 /* Fan monitoring can be disabled. If it is, we won't be polling 1358 /*
1286 the register values, and won't create the related sysfs files. */ 1359 * Fan monitoring can be disabled. If it is, we won't be polling
1360 * the register values, and won't create the related sysfs files.
1361 */
1287 for (i = 0; i < 3; i++) { 1362 for (i = 0; i < 3; i++) {
1288 data->fan_ctrl[i] = f71805f_read8(data, 1363 data->fan_ctrl[i] = f71805f_read8(data,
1289 F71805F_REG_FAN_CTRL(i)); 1364 F71805F_REG_FAN_CTRL(i));
1290 /* Clear latch full bit, else "speed mode" fan speed control 1365 /*
1291 doesn't work */ 1366 * Clear latch full bit, else "speed mode" fan speed control
1367 * doesn't work
1368 */
1292 if (data->fan_ctrl[i] & FAN_CTRL_LATCH_FULL) { 1369 if (data->fan_ctrl[i] & FAN_CTRL_LATCH_FULL) {
1293 data->fan_ctrl[i] &= ~FAN_CTRL_LATCH_FULL; 1370 data->fan_ctrl[i] &= ~FAN_CTRL_LATCH_FULL;
1294 f71805f_write8(data, F71805F_REG_FAN_CTRL(i), 1371 f71805f_write8(data, F71805F_REG_FAN_CTRL(i),
@@ -1304,12 +1381,13 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
1304 struct resource *res; 1381 struct resource *res;
1305 int i, err; 1382 int i, err;
1306 1383
1307 static const char *names[] = { 1384 static const char * const names[] = {
1308 "f71805f", 1385 "f71805f",
1309 "f71872f", 1386 "f71872f",
1310 }; 1387 };
1311 1388
1312 if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) { 1389 data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL);
1390 if (!data) {
1313 err = -ENOMEM; 1391 err = -ENOMEM;
1314 pr_err("Out of memory\n"); 1392 pr_err("Out of memory\n");
1315 goto exit; 1393 goto exit;
@@ -1347,40 +1425,47 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
1347 f71805f_init_device(data); 1425 f71805f_init_device(data);
1348 1426
1349 /* Register sysfs interface files */ 1427 /* Register sysfs interface files */
1350 if ((err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group))) 1428 err = sysfs_create_group(&pdev->dev.kobj, &f71805f_group);
1429 if (err)
1351 goto exit_release_region; 1430 goto exit_release_region;
1352 if (data->has_in & (1 << 4)) { /* in4 */ 1431 if (data->has_in & (1 << 4)) { /* in4 */
1353 if ((err = sysfs_create_group(&pdev->dev.kobj, 1432 err = sysfs_create_group(&pdev->dev.kobj,
1354 &f71805f_group_optin[0]))) 1433 &f71805f_group_optin[0]);
1434 if (err)
1355 goto exit_remove_files; 1435 goto exit_remove_files;
1356 } 1436 }
1357 if (data->has_in & (1 << 8)) { /* in8 */ 1437 if (data->has_in & (1 << 8)) { /* in8 */
1358 if ((err = sysfs_create_group(&pdev->dev.kobj, 1438 err = sysfs_create_group(&pdev->dev.kobj,
1359 &f71805f_group_optin[1]))) 1439 &f71805f_group_optin[1]);
1440 if (err)
1360 goto exit_remove_files; 1441 goto exit_remove_files;
1361 } 1442 }
1362 if (data->has_in & (1 << 9)) { /* in9 (F71872F/FG only) */ 1443 if (data->has_in & (1 << 9)) { /* in9 (F71872F/FG only) */
1363 if ((err = sysfs_create_group(&pdev->dev.kobj, 1444 err = sysfs_create_group(&pdev->dev.kobj,
1364 &f71805f_group_optin[2]))) 1445 &f71805f_group_optin[2]);
1446 if (err)
1365 goto exit_remove_files; 1447 goto exit_remove_files;
1366 } 1448 }
1367 if (data->has_in & (1 << 10)) { /* in9 (F71872F/FG only) */ 1449 if (data->has_in & (1 << 10)) { /* in9 (F71872F/FG only) */
1368 if ((err = sysfs_create_group(&pdev->dev.kobj, 1450 err = sysfs_create_group(&pdev->dev.kobj,
1369 &f71805f_group_optin[3]))) 1451 &f71805f_group_optin[3]);
1452 if (err)
1370 goto exit_remove_files; 1453 goto exit_remove_files;
1371 } 1454 }
1372 for (i = 0; i < 3; i++) { 1455 for (i = 0; i < 3; i++) {
1373 /* If control mode is PWM, create pwm_freq file */ 1456 /* If control mode is PWM, create pwm_freq file */
1374 if (!(data->fan_ctrl[i] & FAN_CTRL_DC_MODE)) { 1457 if (!(data->fan_ctrl[i] & FAN_CTRL_DC_MODE)) {
1375 if ((err = sysfs_create_file(&pdev->dev.kobj, 1458 err = sysfs_create_file(&pdev->dev.kobj,
1376 f71805f_attributes_pwm_freq[i]))) 1459 f71805f_attributes_pwm_freq[i]);
1460 if (err)
1377 goto exit_remove_files; 1461 goto exit_remove_files;
1378 } 1462 }
1379 /* If PWM is in manual mode, add write permission */ 1463 /* If PWM is in manual mode, add write permission */
1380 if (data->fan_ctrl[i] & FAN_CTRL_MODE_MANUAL) { 1464 if (data->fan_ctrl[i] & FAN_CTRL_MODE_MANUAL) {
1381 if ((err = sysfs_chmod_file(&pdev->dev.kobj, 1465 err = sysfs_chmod_file(&pdev->dev.kobj,
1382 f71805f_attr_pwm[i], 1466 f71805f_attr_pwm[i],
1383 S_IRUGO | S_IWUSR))) { 1467 S_IRUGO | S_IWUSR);
1468 if (err) {
1384 dev_err(&pdev->dev, "chmod +w pwm%d failed\n", 1469 dev_err(&pdev->dev, "chmod +w pwm%d failed\n",
1385 i + 1); 1470 i + 1);
1386 goto exit_remove_files; 1471 goto exit_remove_files;
@@ -1495,7 +1580,7 @@ static int __init f71805f_find(int sioaddr, unsigned short *address,
1495 int err = -ENODEV; 1580 int err = -ENODEV;
1496 u16 devid; 1581 u16 devid;
1497 1582
1498 static const char *names[] = { 1583 static const char * const names[] = {
1499 "F71805F/FG", 1584 "F71805F/FG",
1500 "F71872F/FG or F71806F/FG", 1585 "F71872F/FG or F71806F/FG",
1501 }; 1586 };