aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1021.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm1021.c')
-rw-r--r--drivers/hwmon/adm1021.c97
1 files changed, 55 insertions, 42 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index 0158cc35cb2e..4394e7e99c46 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -1,23 +1,23 @@
1/* 1/*
2 adm1021.c - Part of lm_sensors, Linux kernel modules for hardware 2 * adm1021.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring 3 * monitoring
4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and 4 * Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and
5 Philip Edelbrock <phil@netroedge.com> 5 * Philip Edelbrock <phil@netroedge.com>
6 6 *
7 This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 * (at your option) any later version.
11 11 *
12 This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 * GNU General Public License for more details.
16 16 *
17 You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 20 */
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/init.h> 23#include <linux/init.h>
@@ -70,10 +70,12 @@ enum chips {
70 70
71/* Initial values */ 71/* Initial values */
72 72
73/* Note: Even though I left the low and high limits named os and hyst, 73/*
74they don't quite work like a thermostat the way the LM75 does. I.e., 74 * Note: Even though I left the low and high limits named os and hyst,
75a lower temp than THYST actually triggers an alarm instead of 75 * they don't quite work like a thermostat the way the LM75 does. I.e.,
76clearing it. Weird, ey? --Phil */ 76 * a lower temp than THYST actually triggers an alarm instead of
77 * clearing it. Weird, ey? --Phil
78 */
77 79
78/* Each client has this additional data */ 80/* Each client has this additional data */
79struct adm1021_data { 81struct adm1021_data {
@@ -182,7 +184,13 @@ static ssize_t set_temp_max(struct device *dev,
182 int index = to_sensor_dev_attr(devattr)->index; 184 int index = to_sensor_dev_attr(devattr)->index;
183 struct i2c_client *client = to_i2c_client(dev); 185 struct i2c_client *client = to_i2c_client(dev);
184 struct adm1021_data *data = i2c_get_clientdata(client); 186 struct adm1021_data *data = i2c_get_clientdata(client);
185 long temp = simple_strtol(buf, NULL, 10) / 1000; 187 long temp;
188 int err;
189
190 err = kstrtol(buf, 10, &temp);
191 if (err)
192 return err;
193 temp /= 1000;
186 194
187 mutex_lock(&data->update_lock); 195 mutex_lock(&data->update_lock);
188 data->temp_max[index] = SENSORS_LIMIT(temp, -128, 127); 196 data->temp_max[index] = SENSORS_LIMIT(temp, -128, 127);
@@ -201,7 +209,13 @@ static ssize_t set_temp_min(struct device *dev,
201 int index = to_sensor_dev_attr(devattr)->index; 209 int index = to_sensor_dev_attr(devattr)->index;
202 struct i2c_client *client = to_i2c_client(dev); 210 struct i2c_client *client = to_i2c_client(dev);
203 struct adm1021_data *data = i2c_get_clientdata(client); 211 struct adm1021_data *data = i2c_get_clientdata(client);
204 long temp = simple_strtol(buf, NULL, 10) / 1000; 212 long temp;
213 int err;
214
215 err = kstrtol(buf, 10, &temp);
216 if (err)
217 return err;
218 temp /= 1000;
205 219
206 mutex_lock(&data->update_lock); 220 mutex_lock(&data->update_lock);
207 data->temp_min[index] = SENSORS_LIMIT(temp, -128, 127); 221 data->temp_min[index] = SENSORS_LIMIT(temp, -128, 127);
@@ -226,7 +240,14 @@ static ssize_t set_low_power(struct device *dev,
226{ 240{
227 struct i2c_client *client = to_i2c_client(dev); 241 struct i2c_client *client = to_i2c_client(dev);
228 struct adm1021_data *data = i2c_get_clientdata(client); 242 struct adm1021_data *data = i2c_get_clientdata(client);
229 int low_power = simple_strtol(buf, NULL, 10) != 0; 243 char low_power;
244 unsigned long val;
245 int err;
246
247 err = kstrtoul(buf, 10, &val);
248 if (err)
249 return err;
250 low_power = val != 0;
230 251
231 mutex_lock(&data->update_lock); 252 mutex_lock(&data->update_lock);
232 if (low_power != data->low_power) { 253 if (low_power != data->low_power) {
@@ -361,7 +382,8 @@ static int adm1021_probe(struct i2c_client *client,
361 adm1021_init_client(client); 382 adm1021_init_client(client);
362 383
363 /* Register sysfs hooks */ 384 /* Register sysfs hooks */
364 if ((err = sysfs_create_group(&client->dev.kobj, &adm1021_group))) 385 err = sysfs_create_group(&client->dev.kobj, &adm1021_group);
386 if (err)
365 goto error1; 387 goto error1;
366 388
367 data->hwmon_dev = hwmon_device_register(&client->dev); 389 data->hwmon_dev = hwmon_device_register(&client->dev);
@@ -427,8 +449,10 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
427 data->alarms = i2c_smbus_read_byte_data(client, 449 data->alarms = i2c_smbus_read_byte_data(client,
428 ADM1021_REG_STATUS) & 0x7c; 450 ADM1021_REG_STATUS) & 0x7c;
429 if (data->type == adm1023) { 451 if (data->type == adm1023) {
430 /* The ADM1023 provides 3 extra bits of precision for 452 /*
431 * the remote sensor in extra registers. */ 453 * The ADM1023 provides 3 extra bits of precision for
454 * the remote sensor in extra registers.
455 */
432 data->temp[1] += 125 * (i2c_smbus_read_byte_data( 456 data->temp[1] += 125 * (i2c_smbus_read_byte_data(
433 client, ADM1023_REG_REM_TEMP_PREC) >> 5); 457 client, ADM1023_REG_REM_TEMP_PREC) >> 5);
434 data->temp_max[1] += 125 * (i2c_smbus_read_byte_data( 458 data->temp_max[1] += 125 * (i2c_smbus_read_byte_data(
@@ -451,23 +475,12 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
451 return data; 475 return data;
452} 476}
453 477
454static int __init sensors_adm1021_init(void) 478module_i2c_driver(adm1021_driver);
455{
456 return i2c_add_driver(&adm1021_driver);
457}
458
459static void __exit sensors_adm1021_exit(void)
460{
461 i2c_del_driver(&adm1021_driver);
462}
463 479
464MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl> and " 480MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and "
465 "Philip Edelbrock <phil@netroedge.com>"); 481 "Philip Edelbrock <phil@netroedge.com>");
466MODULE_DESCRIPTION("adm1021 driver"); 482MODULE_DESCRIPTION("adm1021 driver");
467MODULE_LICENSE("GPL"); 483MODULE_LICENSE("GPL");
468 484
469module_param(read_only, bool, 0); 485module_param(read_only, bool, 0);
470MODULE_PARM_DESC(read_only, "Don't set any values, read only mode"); 486MODULE_PARM_DESC(read_only, "Don't set any values, read only mode");
471
472module_init(sensors_adm1021_init)
473module_exit(sensors_adm1021_exit)