aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/asc7621.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/hwmon/asc7621.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/hwmon/asc7621.c')
-rw-r--r--drivers/hwmon/asc7621.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/drivers/hwmon/asc7621.c b/drivers/hwmon/asc7621.c
index b867aab7804..d2596cec18b 100644
--- a/drivers/hwmon/asc7621.c
+++ b/drivers/hwmon/asc7621.c
@@ -188,7 +188,7 @@ static ssize_t store_u8(struct device *dev, struct device_attribute *attr,
188 SETUP_STORE_data_param(dev, attr); 188 SETUP_STORE_data_param(dev, attr);
189 long reqval; 189 long reqval;
190 190
191 if (kstrtol(buf, 10, &reqval)) 191 if (strict_strtol(buf, 10, &reqval))
192 return -EINVAL; 192 return -EINVAL;
193 193
194 reqval = SENSORS_LIMIT(reqval, 0, 255); 194 reqval = SENSORS_LIMIT(reqval, 0, 255);
@@ -221,7 +221,7 @@ static ssize_t store_bitmask(struct device *dev,
221 long reqval; 221 long reqval;
222 u8 currval; 222 u8 currval;
223 223
224 if (kstrtol(buf, 10, &reqval)) 224 if (strict_strtol(buf, 10, &reqval))
225 return -EINVAL; 225 return -EINVAL;
226 226
227 reqval = SENSORS_LIMIT(reqval, 0, param->mask[0]); 227 reqval = SENSORS_LIMIT(reqval, 0, param->mask[0]);
@@ -265,14 +265,12 @@ static ssize_t store_fan16(struct device *dev,
265 SETUP_STORE_data_param(dev, attr); 265 SETUP_STORE_data_param(dev, attr);
266 long reqval; 266 long reqval;
267 267
268 if (kstrtol(buf, 10, &reqval)) 268 if (strict_strtol(buf, 10, &reqval))
269 return -EINVAL; 269 return -EINVAL;
270 270
271 /* 271 /* If a minimum RPM of zero is requested, then we set the register to
272 * If a minimum RPM of zero is requested, then we set the register to 272 0xffff. This value allows the fan to be stopped completely without
273 * 0xffff. This value allows the fan to be stopped completely without 273 generating an alarm. */
274 * generating an alarm.
275 */
276 reqval = 274 reqval =
277 (reqval <= 0 ? 0xffff : SENSORS_LIMIT(5400000 / reqval, 0, 0xfffe)); 275 (reqval <= 0 ? 0xffff : SENSORS_LIMIT(5400000 / reqval, 0, 0xfffe));
278 276
@@ -340,7 +338,7 @@ static ssize_t store_in8(struct device *dev, struct device_attribute *attr,
340 long reqval; 338 long reqval;
341 u8 nr = sda->index; 339 u8 nr = sda->index;
342 340
343 if (kstrtol(buf, 10, &reqval)) 341 if (strict_strtol(buf, 10, &reqval))
344 return -EINVAL; 342 return -EINVAL;
345 343
346 reqval = SENSORS_LIMIT(reqval, 0, 0xffff); 344 reqval = SENSORS_LIMIT(reqval, 0, 0xffff);
@@ -373,7 +371,7 @@ static ssize_t store_temp8(struct device *dev,
373 long reqval; 371 long reqval;
374 s8 temp; 372 s8 temp;
375 373
376 if (kstrtol(buf, 10, &reqval)) 374 if (strict_strtol(buf, 10, &reqval))
377 return -EINVAL; 375 return -EINVAL;
378 376
379 reqval = SENSORS_LIMIT(reqval, -127000, 127000); 377 reqval = SENSORS_LIMIT(reqval, -127000, 127000);
@@ -429,7 +427,7 @@ static ssize_t store_temp62(struct device *dev,
429 long reqval, i, f; 427 long reqval, i, f;
430 s8 temp; 428 s8 temp;
431 429
432 if (kstrtol(buf, 10, &reqval)) 430 if (strict_strtol(buf, 10, &reqval))
433 return -EINVAL; 431 return -EINVAL;
434 432
435 reqval = SENSORS_LIMIT(reqval, -32000, 31750); 433 reqval = SENSORS_LIMIT(reqval, -32000, 31750);
@@ -484,7 +482,7 @@ static ssize_t store_ap2_temp(struct device *dev,
484 int i; 482 int i;
485 u8 currval, newval = 0; 483 u8 currval, newval = 0;
486 484
487 if (kstrtol(buf, 10, &reqval)) 485 if (strict_strtol(buf, 10, &reqval))
488 return -EINVAL; 486 return -EINVAL;
489 487
490 mutex_lock(&data->update_lock); 488 mutex_lock(&data->update_lock);
@@ -540,7 +538,7 @@ static ssize_t store_pwm_ac(struct device *dev,
540 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 538 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
541 }; 539 };
542 540
543 if (kstrtoul(buf, 10, &reqval)) 541 if (strict_strtoul(buf, 10, &reqval))
544 return -EINVAL; 542 return -EINVAL;
545 543
546 if (reqval > 31) 544 if (reqval > 31)
@@ -603,7 +601,7 @@ static ssize_t store_pwm_enable(struct device *dev,
603 long reqval; 601 long reqval;
604 u8 currval, config, altbit, newval, minoff = 255; 602 u8 currval, config, altbit, newval, minoff = 255;
605 603
606 if (kstrtol(buf, 10, &reqval)) 604 if (strict_strtol(buf, 10, &reqval))
607 return -EINVAL; 605 return -EINVAL;
608 606
609 switch (reqval) { 607 switch (reqval) {
@@ -677,7 +675,7 @@ static ssize_t store_pwm_freq(struct device *dev,
677 u8 currval, newval = 255; 675 u8 currval, newval = 255;
678 int i; 676 int i;
679 677
680 if (kstrtoul(buf, 10, &reqval)) 678 if (strict_strtoul(buf, 10, &reqval))
681 return -EINVAL; 679 return -EINVAL;
682 680
683 for (i = 0; i < ARRAY_SIZE(asc7621_pwm_freq_map); i++) { 681 for (i = 0; i < ARRAY_SIZE(asc7621_pwm_freq_map); i++) {
@@ -726,7 +724,7 @@ static ssize_t store_pwm_ast(struct device *dev,
726 u8 currval, newval = 255; 724 u8 currval, newval = 255;
727 u32 i; 725 u32 i;
728 726
729 if (kstrtol(buf, 10, &reqval)) 727 if (strict_strtol(buf, 10, &reqval))
730 return -EINVAL; 728 return -EINVAL;
731 729
732 for (i = 0; i < ARRAY_SIZE(asc7621_pwm_auto_spinup_map); i++) { 730 for (i = 0; i < ARRAY_SIZE(asc7621_pwm_auto_spinup_map); i++) {
@@ -773,7 +771,7 @@ static ssize_t store_temp_st(struct device *dev,
773 u8 currval, newval = 255; 771 u8 currval, newval = 255;
774 u32 i; 772 u32 i;
775 773
776 if (kstrtol(buf, 10, &reqval)) 774 if (strict_strtol(buf, 10, &reqval))
777 return -EINVAL; 775 return -EINVAL;
778 776
779 for (i = 0; i < ARRAY_SIZE(asc7621_temp_smoothing_time_map); i++) { 777 for (i = 0; i < ARRAY_SIZE(asc7621_temp_smoothing_time_map); i++) {
@@ -1109,8 +1107,7 @@ asc7621_probe(struct i2c_client *client, const struct i2c_device_id *id)
1109 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 1107 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
1110 return -EIO; 1108 return -EIO;
1111 1109
1112 data = devm_kzalloc(&client->dev, sizeof(struct asc7621_data), 1110 data = kzalloc(sizeof(struct asc7621_data), GFP_KERNEL);
1113 GFP_KERNEL);
1114 if (data == NULL) 1111 if (data == NULL)
1115 return -ENOMEM; 1112 return -ENOMEM;
1116 1113
@@ -1144,6 +1141,7 @@ exit_remove:
1144 &(asc7621_params[i].sda.dev_attr)); 1141 &(asc7621_params[i].sda.dev_attr));
1145 } 1142 }
1146 1143
1144 kfree(data);
1147 return err; 1145 return err;
1148} 1146}
1149 1147
@@ -1192,6 +1190,7 @@ static int asc7621_remove(struct i2c_client *client)
1192 &(asc7621_params[i].sda.dev_attr)); 1190 &(asc7621_params[i].sda.dev_attr));
1193 } 1191 }
1194 1192
1193 kfree(data);
1195 return 0; 1194 return 0;
1196} 1195}
1197 1196