diff options
| -rw-r--r-- | drivers/hwmon/it87.c | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 96306a6f844e..8282282eb4ca 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
| @@ -363,7 +363,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
| 363 | int nr = sensor_attr->index; | 363 | int nr = sensor_attr->index; |
| 364 | 364 | ||
| 365 | struct it87_data *data = dev_get_drvdata(dev); | 365 | struct it87_data *data = dev_get_drvdata(dev); |
| 366 | unsigned long val = simple_strtoul(buf, NULL, 10); | 366 | unsigned long val; |
| 367 | |||
| 368 | if (strict_strtoul(buf, 10, &val) < 0) | ||
| 369 | return -EINVAL; | ||
| 367 | 370 | ||
| 368 | mutex_lock(&data->update_lock); | 371 | mutex_lock(&data->update_lock); |
| 369 | data->in_min[nr] = IN_TO_REG(val); | 372 | data->in_min[nr] = IN_TO_REG(val); |
| @@ -379,7 +382,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
| 379 | int nr = sensor_attr->index; | 382 | int nr = sensor_attr->index; |
| 380 | 383 | ||
| 381 | struct it87_data *data = dev_get_drvdata(dev); | 384 | struct it87_data *data = dev_get_drvdata(dev); |
| 382 | unsigned long val = simple_strtoul(buf, NULL, 10); | 385 | unsigned long val; |
| 386 | |||
| 387 | if (strict_strtoul(buf, 10, &val) < 0) | ||
| 388 | return -EINVAL; | ||
| 383 | 389 | ||
| 384 | mutex_lock(&data->update_lock); | 390 | mutex_lock(&data->update_lock); |
| 385 | data->in_max[nr] = IN_TO_REG(val); | 391 | data->in_max[nr] = IN_TO_REG(val); |
| @@ -452,7 +458,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
| 452 | int nr = sensor_attr->index; | 458 | int nr = sensor_attr->index; |
| 453 | 459 | ||
| 454 | struct it87_data *data = dev_get_drvdata(dev); | 460 | struct it87_data *data = dev_get_drvdata(dev); |
| 455 | int val = simple_strtol(buf, NULL, 10); | 461 | long val; |
| 462 | |||
| 463 | if (strict_strtol(buf, 10, &val) < 0) | ||
| 464 | return -EINVAL; | ||
| 456 | 465 | ||
| 457 | mutex_lock(&data->update_lock); | 466 | mutex_lock(&data->update_lock); |
| 458 | data->temp_high[nr] = TEMP_TO_REG(val); | 467 | data->temp_high[nr] = TEMP_TO_REG(val); |
| @@ -467,7 +476,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
| 467 | int nr = sensor_attr->index; | 476 | int nr = sensor_attr->index; |
| 468 | 477 | ||
| 469 | struct it87_data *data = dev_get_drvdata(dev); | 478 | struct it87_data *data = dev_get_drvdata(dev); |
| 470 | int val = simple_strtol(buf, NULL, 10); | 479 | long val; |
| 480 | |||
| 481 | if (strict_strtol(buf, 10, &val) < 0) | ||
| 482 | return -EINVAL; | ||
| 471 | 483 | ||
| 472 | mutex_lock(&data->update_lock); | 484 | mutex_lock(&data->update_lock); |
| 473 | data->temp_low[nr] = TEMP_TO_REG(val); | 485 | data->temp_low[nr] = TEMP_TO_REG(val); |
| @@ -510,7 +522,10 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, | |||
| 510 | int nr = sensor_attr->index; | 522 | int nr = sensor_attr->index; |
| 511 | 523 | ||
| 512 | struct it87_data *data = dev_get_drvdata(dev); | 524 | struct it87_data *data = dev_get_drvdata(dev); |
| 513 | int val = simple_strtol(buf, NULL, 10); | 525 | long val; |
| 526 | |||
| 527 | if (strict_strtol(buf, 10, &val) < 0) | ||
| 528 | return -EINVAL; | ||
| 514 | 529 | ||
| 515 | mutex_lock(&data->update_lock); | 530 | mutex_lock(&data->update_lock); |
| 516 | 531 | ||
| @@ -618,9 +633,12 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
| 618 | int nr = sensor_attr->index; | 633 | int nr = sensor_attr->index; |
| 619 | 634 | ||
| 620 | struct it87_data *data = dev_get_drvdata(dev); | 635 | struct it87_data *data = dev_get_drvdata(dev); |
| 621 | int val = simple_strtol(buf, NULL, 10); | 636 | long val; |
| 622 | u8 reg; | 637 | u8 reg; |
| 623 | 638 | ||
| 639 | if (strict_strtol(buf, 10, &val) < 0) | ||
| 640 | return -EINVAL; | ||
| 641 | |||
| 624 | mutex_lock(&data->update_lock); | 642 | mutex_lock(&data->update_lock); |
| 625 | reg = it87_read_value(data, IT87_REG_FAN_DIV); | 643 | reg = it87_read_value(data, IT87_REG_FAN_DIV); |
| 626 | switch (nr) { | 644 | switch (nr) { |
| @@ -647,10 +665,13 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
| 647 | int nr = sensor_attr->index; | 665 | int nr = sensor_attr->index; |
| 648 | 666 | ||
| 649 | struct it87_data *data = dev_get_drvdata(dev); | 667 | struct it87_data *data = dev_get_drvdata(dev); |
| 650 | unsigned long val = simple_strtoul(buf, NULL, 10); | 668 | unsigned long val; |
| 651 | int min; | 669 | int min; |
| 652 | u8 old; | 670 | u8 old; |
| 653 | 671 | ||
| 672 | if (strict_strtoul(buf, 10, &val) < 0) | ||
| 673 | return -EINVAL; | ||
| 674 | |||
| 654 | mutex_lock(&data->update_lock); | 675 | mutex_lock(&data->update_lock); |
| 655 | old = it87_read_value(data, IT87_REG_FAN_DIV); | 676 | old = it87_read_value(data, IT87_REG_FAN_DIV); |
| 656 | 677 | ||
| @@ -689,9 +710,9 @@ static ssize_t set_pwm_enable(struct device *dev, | |||
| 689 | int nr = sensor_attr->index; | 710 | int nr = sensor_attr->index; |
| 690 | 711 | ||
| 691 | struct it87_data *data = dev_get_drvdata(dev); | 712 | struct it87_data *data = dev_get_drvdata(dev); |
| 692 | int val = simple_strtol(buf, NULL, 10); | 713 | long val; |
| 693 | 714 | ||
| 694 | if (val < 0 || val > 2) | 715 | if (strict_strtol(buf, 10, &val) < 0 || val < 0 || val > 2) |
| 695 | return -EINVAL; | 716 | return -EINVAL; |
| 696 | 717 | ||
| 697 | mutex_lock(&data->update_lock); | 718 | mutex_lock(&data->update_lock); |
| @@ -727,9 +748,9 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | |||
| 727 | int nr = sensor_attr->index; | 748 | int nr = sensor_attr->index; |
| 728 | 749 | ||
| 729 | struct it87_data *data = dev_get_drvdata(dev); | 750 | struct it87_data *data = dev_get_drvdata(dev); |
| 730 | int val = simple_strtol(buf, NULL, 10); | 751 | long val; |
| 731 | 752 | ||
| 732 | if (val < 0 || val > 255) | 753 | if (strict_strtol(buf, 10, &val) < 0 || val < 0 || val > 255) |
| 733 | return -EINVAL; | 754 | return -EINVAL; |
| 734 | 755 | ||
| 735 | mutex_lock(&data->update_lock); | 756 | mutex_lock(&data->update_lock); |
| @@ -747,9 +768,12 @@ static ssize_t set_pwm_freq(struct device *dev, | |||
| 747 | struct device_attribute *attr, const char *buf, size_t count) | 768 | struct device_attribute *attr, const char *buf, size_t count) |
| 748 | { | 769 | { |
| 749 | struct it87_data *data = dev_get_drvdata(dev); | 770 | struct it87_data *data = dev_get_drvdata(dev); |
| 750 | unsigned long val = simple_strtoul(buf, NULL, 10); | 771 | unsigned long val; |
| 751 | int i; | 772 | int i; |
| 752 | 773 | ||
| 774 | if (strict_strtoul(buf, 10, &val) < 0) | ||
| 775 | return -EINVAL; | ||
| 776 | |||
| 753 | /* Search for the nearest available frequency */ | 777 | /* Search for the nearest available frequency */ |
| 754 | for (i = 0; i < 7; i++) { | 778 | for (i = 0; i < 7; i++) { |
| 755 | if (val > (pwm_freq[i] + pwm_freq[i+1]) / 2) | 779 | if (val > (pwm_freq[i] + pwm_freq[i+1]) / 2) |
| @@ -871,7 +895,10 @@ static ssize_t set_fan16_min(struct device *dev, struct device_attribute *attr, | |||
| 871 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 895 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
| 872 | int nr = sensor_attr->index; | 896 | int nr = sensor_attr->index; |
| 873 | struct it87_data *data = dev_get_drvdata(dev); | 897 | struct it87_data *data = dev_get_drvdata(dev); |
| 874 | int val = simple_strtol(buf, NULL, 10); | 898 | long val; |
| 899 | |||
| 900 | if (strict_strtol(buf, 10, &val) < 0) | ||
| 901 | return -EINVAL; | ||
| 875 | 902 | ||
| 876 | mutex_lock(&data->update_lock); | 903 | mutex_lock(&data->update_lock); |
| 877 | data->fan_min[nr] = FAN16_TO_REG(val); | 904 | data->fan_min[nr] = FAN16_TO_REG(val); |
| @@ -992,9 +1019,11 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, | |||
| 992 | const char *buf, size_t count) | 1019 | const char *buf, size_t count) |
| 993 | { | 1020 | { |
| 994 | struct it87_data *data = dev_get_drvdata(dev); | 1021 | struct it87_data *data = dev_get_drvdata(dev); |
| 995 | u32 val; | 1022 | unsigned long val; |
| 1023 | |||
| 1024 | if (strict_strtoul(buf, 10, &val) < 0) | ||
| 1025 | return -EINVAL; | ||
| 996 | 1026 | ||
| 997 | val = simple_strtoul(buf, NULL, 10); | ||
| 998 | data->vrm = val; | 1027 | data->vrm = val; |
| 999 | 1028 | ||
| 1000 | return count; | 1029 | return count; |
