aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/f71882fg.c133
1 files changed, 104 insertions, 29 deletions
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
index 21bc66159b5a..4230729780c4 100644
--- a/drivers/hwmon/f71882fg.c
+++ b/drivers/hwmon/f71882fg.c
@@ -1127,8 +1127,12 @@ static ssize_t store_fan_full_speed(struct device *dev,
1127 const char *buf, size_t count) 1127 const char *buf, size_t count)
1128{ 1128{
1129 struct f71882fg_data *data = dev_get_drvdata(dev); 1129 struct f71882fg_data *data = dev_get_drvdata(dev);
1130 int nr = to_sensor_dev_attr_2(devattr)->index; 1130 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1131 long val = simple_strtol(buf, NULL, 10); 1131 long val;
1132
1133 err = strict_strtol(buf, 10, &val);
1134 if (err)
1135 return err;
1132 1136
1133 val = SENSORS_LIMIT(val, 23, 1500000); 1137 val = SENSORS_LIMIT(val, 23, 1500000);
1134 val = fan_to_reg(val); 1138 val = fan_to_reg(val);
@@ -1157,8 +1161,12 @@ static ssize_t store_fan_beep(struct device *dev, struct device_attribute
1157 *devattr, const char *buf, size_t count) 1161 *devattr, const char *buf, size_t count)
1158{ 1162{
1159 struct f71882fg_data *data = dev_get_drvdata(dev); 1163 struct f71882fg_data *data = dev_get_drvdata(dev);
1160 int nr = to_sensor_dev_attr_2(devattr)->index; 1164 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1161 unsigned long val = simple_strtoul(buf, NULL, 10); 1165 unsigned long val;
1166
1167 err = strict_strtoul(buf, 10, &val);
1168 if (err)
1169 return err;
1162 1170
1163 mutex_lock(&data->update_lock); 1171 mutex_lock(&data->update_lock);
1164 data->fan_beep = f71882fg_read8(data, F71882FG_REG_FAN_BEEP); 1172 data->fan_beep = f71882fg_read8(data, F71882FG_REG_FAN_BEEP);
@@ -1206,7 +1214,14 @@ static ssize_t store_in_max(struct device *dev, struct device_attribute
1206 *devattr, const char *buf, size_t count) 1214 *devattr, const char *buf, size_t count)
1207{ 1215{
1208 struct f71882fg_data *data = dev_get_drvdata(dev); 1216 struct f71882fg_data *data = dev_get_drvdata(dev);
1209 long val = simple_strtol(buf, NULL, 10) / 8; 1217 int err;
1218 long val;
1219
1220 err = strict_strtol(buf, 10, &val);
1221 if (err)
1222 return err;
1223
1224 val /= 8;
1210 val = SENSORS_LIMIT(val, 0, 255); 1225 val = SENSORS_LIMIT(val, 0, 255);
1211 1226
1212 mutex_lock(&data->update_lock); 1227 mutex_lock(&data->update_lock);
@@ -1233,8 +1248,12 @@ static ssize_t store_in_beep(struct device *dev, struct device_attribute
1233 *devattr, const char *buf, size_t count) 1248 *devattr, const char *buf, size_t count)
1234{ 1249{
1235 struct f71882fg_data *data = dev_get_drvdata(dev); 1250 struct f71882fg_data *data = dev_get_drvdata(dev);
1236 int nr = to_sensor_dev_attr_2(devattr)->index; 1251 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1237 unsigned long val = simple_strtoul(buf, NULL, 10); 1252 unsigned long val;
1253
1254 err = strict_strtoul(buf, 10, &val);
1255 if (err)
1256 return err;
1238 1257
1239 mutex_lock(&data->update_lock); 1258 mutex_lock(&data->update_lock);
1240 data->in_beep = f71882fg_read8(data, F71882FG_REG_IN_BEEP); 1259 data->in_beep = f71882fg_read8(data, F71882FG_REG_IN_BEEP);
@@ -1299,8 +1318,14 @@ static ssize_t store_temp_max(struct device *dev, struct device_attribute
1299 *devattr, const char *buf, size_t count) 1318 *devattr, const char *buf, size_t count)
1300{ 1319{
1301 struct f71882fg_data *data = dev_get_drvdata(dev); 1320 struct f71882fg_data *data = dev_get_drvdata(dev);
1302 int nr = to_sensor_dev_attr_2(devattr)->index; 1321 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1303 long val = simple_strtol(buf, NULL, 10) / 1000; 1322 long val;
1323
1324 err = strict_strtol(buf, 10, &val);
1325 if (err)
1326 return err;
1327
1328 val /= 1000;
1304 val = SENSORS_LIMIT(val, 0, 255); 1329 val = SENSORS_LIMIT(val, 0, 255);
1305 1330
1306 mutex_lock(&data->update_lock); 1331 mutex_lock(&data->update_lock);
@@ -1333,10 +1358,16 @@ static ssize_t store_temp_max_hyst(struct device *dev, struct device_attribute
1333 *devattr, const char *buf, size_t count) 1358 *devattr, const char *buf, size_t count)
1334{ 1359{
1335 struct f71882fg_data *data = dev_get_drvdata(dev); 1360 struct f71882fg_data *data = dev_get_drvdata(dev);
1336 int nr = to_sensor_dev_attr_2(devattr)->index; 1361 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1337 long val = simple_strtol(buf, NULL, 10) / 1000;
1338 ssize_t ret = count; 1362 ssize_t ret = count;
1339 u8 reg; 1363 u8 reg;
1364 long val;
1365
1366 err = strict_strtol(buf, 10, &val);
1367 if (err)
1368 return err;
1369
1370 val /= 1000;
1340 1371
1341 mutex_lock(&data->update_lock); 1372 mutex_lock(&data->update_lock);
1342 1373
@@ -1372,8 +1403,14 @@ static ssize_t store_temp_crit(struct device *dev, struct device_attribute
1372 *devattr, const char *buf, size_t count) 1403 *devattr, const char *buf, size_t count)
1373{ 1404{
1374 struct f71882fg_data *data = dev_get_drvdata(dev); 1405 struct f71882fg_data *data = dev_get_drvdata(dev);
1375 int nr = to_sensor_dev_attr_2(devattr)->index; 1406 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1376 long val = simple_strtol(buf, NULL, 10) / 1000; 1407 long val;
1408
1409 err = strict_strtol(buf, 10, &val);
1410 if (err)
1411 return err;
1412
1413 val /= 1000;
1377 val = SENSORS_LIMIT(val, 0, 255); 1414 val = SENSORS_LIMIT(val, 0, 255);
1378 1415
1379 mutex_lock(&data->update_lock); 1416 mutex_lock(&data->update_lock);
@@ -1427,8 +1464,12 @@ static ssize_t store_temp_beep(struct device *dev, struct device_attribute
1427 *devattr, const char *buf, size_t count) 1464 *devattr, const char *buf, size_t count)
1428{ 1465{
1429 struct f71882fg_data *data = dev_get_drvdata(dev); 1466 struct f71882fg_data *data = dev_get_drvdata(dev);
1430 int nr = to_sensor_dev_attr_2(devattr)->index; 1467 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1431 unsigned long val = simple_strtoul(buf, NULL, 10); 1468 unsigned long val;
1469
1470 err = strict_strtoul(buf, 10, &val);
1471 if (err)
1472 return err;
1432 1473
1433 mutex_lock(&data->update_lock); 1474 mutex_lock(&data->update_lock);
1434 data->temp_beep = f71882fg_read8(data, F71882FG_REG_TEMP_BEEP); 1475 data->temp_beep = f71882fg_read8(data, F71882FG_REG_TEMP_BEEP);
@@ -1490,8 +1531,13 @@ static ssize_t store_pwm(struct device *dev,
1490 size_t count) 1531 size_t count)
1491{ 1532{
1492 struct f71882fg_data *data = dev_get_drvdata(dev); 1533 struct f71882fg_data *data = dev_get_drvdata(dev);
1493 int nr = to_sensor_dev_attr_2(devattr)->index; 1534 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1494 long val = simple_strtol(buf, NULL, 10); 1535 long val;
1536
1537 err = strict_strtol(buf, 10, &val);
1538 if (err)
1539 return err;
1540
1495 val = SENSORS_LIMIT(val, 0, 255); 1541 val = SENSORS_LIMIT(val, 0, 255);
1496 1542
1497 mutex_lock(&data->update_lock); 1543 mutex_lock(&data->update_lock);
@@ -1551,8 +1597,12 @@ static ssize_t store_pwm_enable(struct device *dev, struct device_attribute
1551 *devattr, const char *buf, size_t count) 1597 *devattr, const char *buf, size_t count)
1552{ 1598{
1553 struct f71882fg_data *data = dev_get_drvdata(dev); 1599 struct f71882fg_data *data = dev_get_drvdata(dev);
1554 int nr = to_sensor_dev_attr_2(devattr)->index; 1600 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1555 long val = simple_strtol(buf, NULL, 10); 1601 long val;
1602
1603 err = strict_strtol(buf, 10, &val);
1604 if (err)
1605 return err;
1556 1606
1557 /* Special case for F8000 pwm channel 3 which only does auto mode */ 1607 /* Special case for F8000 pwm channel 3 which only does auto mode */
1558 if (data->type == f8000 && nr == 2 && val != 2) 1608 if (data->type == f8000 && nr == 2 && val != 2)
@@ -1626,9 +1676,14 @@ static ssize_t store_pwm_auto_point_pwm(struct device *dev,
1626 const char *buf, size_t count) 1676 const char *buf, size_t count)
1627{ 1677{
1628 struct f71882fg_data *data = dev_get_drvdata(dev); 1678 struct f71882fg_data *data = dev_get_drvdata(dev);
1629 int pwm = to_sensor_dev_attr_2(devattr)->index; 1679 int err, pwm = to_sensor_dev_attr_2(devattr)->index;
1630 int point = to_sensor_dev_attr_2(devattr)->nr; 1680 int point = to_sensor_dev_attr_2(devattr)->nr;
1631 long val = simple_strtol(buf, NULL, 10); 1681 long val;
1682
1683 err = strict_strtol(buf, 10, &val);
1684 if (err)
1685 return err;
1686
1632 val = SENSORS_LIMIT(val, 0, 255); 1687 val = SENSORS_LIMIT(val, 0, 255);
1633 1688
1634 mutex_lock(&data->update_lock); 1689 mutex_lock(&data->update_lock);
@@ -1674,10 +1729,16 @@ static ssize_t store_pwm_auto_point_temp_hyst(struct device *dev,
1674 const char *buf, size_t count) 1729 const char *buf, size_t count)
1675{ 1730{
1676 struct f71882fg_data *data = dev_get_drvdata(dev); 1731 struct f71882fg_data *data = dev_get_drvdata(dev);
1677 int nr = to_sensor_dev_attr_2(devattr)->index; 1732 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1678 int point = to_sensor_dev_attr_2(devattr)->nr; 1733 int point = to_sensor_dev_attr_2(devattr)->nr;
1679 long val = simple_strtol(buf, NULL, 10) / 1000;
1680 u8 reg; 1734 u8 reg;
1735 long val;
1736
1737 err = strict_strtol(buf, 10, &val);
1738 if (err)
1739 return err;
1740
1741 val /= 1000;
1681 1742
1682 mutex_lock(&data->update_lock); 1743 mutex_lock(&data->update_lock);
1683 data->pwm_auto_point_temp[nr][point] = 1744 data->pwm_auto_point_temp[nr][point] =
@@ -1716,8 +1777,12 @@ static ssize_t store_pwm_interpolate(struct device *dev,
1716 const char *buf, size_t count) 1777 const char *buf, size_t count)
1717{ 1778{
1718 struct f71882fg_data *data = dev_get_drvdata(dev); 1779 struct f71882fg_data *data = dev_get_drvdata(dev);
1719 int nr = to_sensor_dev_attr_2(devattr)->index; 1780 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1720 unsigned long val = simple_strtoul(buf, NULL, 10); 1781 unsigned long val;
1782
1783 err = strict_strtoul(buf, 10, &val);
1784 if (err)
1785 return err;
1721 1786
1722 mutex_lock(&data->update_lock); 1787 mutex_lock(&data->update_lock);
1723 data->pwm_auto_point_mapping[nr] = 1788 data->pwm_auto_point_mapping[nr] =
@@ -1752,8 +1817,12 @@ static ssize_t store_pwm_auto_point_channel(struct device *dev,
1752 const char *buf, size_t count) 1817 const char *buf, size_t count)
1753{ 1818{
1754 struct f71882fg_data *data = dev_get_drvdata(dev); 1819 struct f71882fg_data *data = dev_get_drvdata(dev);
1755 int nr = to_sensor_dev_attr_2(devattr)->index; 1820 int err, nr = to_sensor_dev_attr_2(devattr)->index;
1756 long val = simple_strtol(buf, NULL, 10); 1821 long val;
1822
1823 err = strict_strtol(buf, 10, &val);
1824 if (err)
1825 return err;
1757 1826
1758 switch (val) { 1827 switch (val) {
1759 case 1: 1828 case 1:
@@ -1798,9 +1867,15 @@ static ssize_t store_pwm_auto_point_temp(struct device *dev,
1798 const char *buf, size_t count) 1867 const char *buf, size_t count)
1799{ 1868{
1800 struct f71882fg_data *data = dev_get_drvdata(dev); 1869 struct f71882fg_data *data = dev_get_drvdata(dev);
1801 int pwm = to_sensor_dev_attr_2(devattr)->index; 1870 int err, pwm = to_sensor_dev_attr_2(devattr)->index;
1802 int point = to_sensor_dev_attr_2(devattr)->nr; 1871 int point = to_sensor_dev_attr_2(devattr)->nr;
1803 long val = simple_strtol(buf, NULL, 10) / 1000; 1872 long val;
1873
1874 err = strict_strtol(buf, 10, &val);
1875 if (err)
1876 return err;
1877
1878 val /= 1000;
1804 1879
1805 if (data->type == f71889fg) 1880 if (data->type == f71889fg)
1806 val = SENSORS_LIMIT(val, -128, 127); 1881 val = SENSORS_LIMIT(val, -128, 127);