aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/thmc50.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/thmc50.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/hwmon/thmc50.c')
-rw-r--r--drivers/hwmon/thmc50.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c
index 3c2c48d904e..7dfb4dec4c5 100644
--- a/drivers/hwmon/thmc50.c
+++ b/drivers/hwmon/thmc50.c
@@ -1,24 +1,24 @@
1/* 1/*
2 * thmc50.c - Part of lm_sensors, Linux kernel modules for hardware 2 thmc50.c - Part of lm_sensors, Linux kernel modules for hardware
3 * monitoring 3 monitoring
4 * Copyright (C) 2007 Krzysztof Helt <krzysztof.h1@wp.pl> 4 Copyright (C) 2007 Krzysztof Helt <krzysztof.h1@wp.pl>
5 * Based on 2.4 driver by Frodo Looijaard <frodol@dds.nl> and 5 Based on 2.4 driver by Frodo Looijaard <frodol@dds.nl> and
6 * Philip Edelbrock <phil@netroedge.com> 6 Philip Edelbrock <phil@netroedge.com>
7 * 7
8 * This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 (at your option) any later version.
12 * 12
13 * This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 GNU General Public License for more details.
17 * 17
18 * You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */ 21*/
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/init.h> 24#include <linux/init.h>
@@ -28,7 +28,6 @@
28#include <linux/hwmon-sysfs.h> 28#include <linux/hwmon-sysfs.h>
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/mutex.h> 30#include <linux/mutex.h>
31#include <linux/jiffies.h>
32 31
33MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
34 33
@@ -125,13 +124,8 @@ static ssize_t set_analog_out(struct device *dev,
125{ 124{
126 struct i2c_client *client = to_i2c_client(dev); 125 struct i2c_client *client = to_i2c_client(dev);
127 struct thmc50_data *data = i2c_get_clientdata(client); 126 struct thmc50_data *data = i2c_get_clientdata(client);
127 int tmp = simple_strtoul(buf, NULL, 10);
128 int config; 128 int config;
129 unsigned long tmp;
130 int err;
131
132 err = kstrtoul(buf, 10, &tmp);
133 if (err)
134 return err;
135 129
136 mutex_lock(&data->update_lock); 130 mutex_lock(&data->update_lock);
137 data->analog_out = SENSORS_LIMIT(tmp, 0, 255); 131 data->analog_out = SENSORS_LIMIT(tmp, 0, 255);
@@ -179,12 +173,7 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
179 int nr = to_sensor_dev_attr(attr)->index; 173 int nr = to_sensor_dev_attr(attr)->index;
180 struct i2c_client *client = to_i2c_client(dev); 174 struct i2c_client *client = to_i2c_client(dev);
181 struct thmc50_data *data = i2c_get_clientdata(client); 175 struct thmc50_data *data = i2c_get_clientdata(client);
182 long val; 176 int val = simple_strtol(buf, NULL, 10);
183 int err;
184
185 err = kstrtol(buf, 10, &val);
186 if (err)
187 return err;
188 177
189 mutex_lock(&data->update_lock); 178 mutex_lock(&data->update_lock);
190 data->temp_min[nr] = SENSORS_LIMIT(val / 1000, -128, 127); 179 data->temp_min[nr] = SENSORS_LIMIT(val / 1000, -128, 127);
@@ -208,12 +197,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
208 int nr = to_sensor_dev_attr(attr)->index; 197 int nr = to_sensor_dev_attr(attr)->index;
209 struct i2c_client *client = to_i2c_client(dev); 198 struct i2c_client *client = to_i2c_client(dev);
210 struct thmc50_data *data = i2c_get_clientdata(client); 199 struct thmc50_data *data = i2c_get_clientdata(client);
211 long val; 200 int val = simple_strtol(buf, NULL, 10);
212 int err;
213
214 err = kstrtol(buf, 10, &val);
215 if (err)
216 return err;
217 201
218 mutex_lock(&data->update_lock); 202 mutex_lock(&data->update_lock);
219 data->temp_max[nr] = SENSORS_LIMIT(val / 1000, -128, 127); 203 data->temp_max[nr] = SENSORS_LIMIT(val / 1000, -128, 127);
@@ -362,10 +346,12 @@ static int thmc50_probe(struct i2c_client *client,
362 struct thmc50_data *data; 346 struct thmc50_data *data;
363 int err; 347 int err;
364 348
365 data = devm_kzalloc(&client->dev, sizeof(struct thmc50_data), 349 data = kzalloc(sizeof(struct thmc50_data), GFP_KERNEL);
366 GFP_KERNEL); 350 if (!data) {
367 if (!data) 351 pr_debug("thmc50: detect failed, kzalloc failed!\n");
368 return -ENOMEM; 352 err = -ENOMEM;
353 goto exit;
354 }
369 355
370 i2c_set_clientdata(client, data); 356 i2c_set_clientdata(client, data);
371 data->type = id->driver_data; 357 data->type = id->driver_data;
@@ -374,16 +360,14 @@ static int thmc50_probe(struct i2c_client *client,
374 thmc50_init_client(client); 360 thmc50_init_client(client);
375 361
376 /* Register sysfs hooks */ 362 /* Register sysfs hooks */
377 err = sysfs_create_group(&client->dev.kobj, &thmc50_group); 363 if ((err = sysfs_create_group(&client->dev.kobj, &thmc50_group)))
378 if (err) 364 goto exit_free;
379 return err;
380 365
381 /* Register ADM1022 sysfs hooks */ 366 /* Register ADM1022 sysfs hooks */
382 if (data->has_temp3) { 367 if (data->has_temp3)
383 err = sysfs_create_group(&client->dev.kobj, &temp3_group); 368 if ((err = sysfs_create_group(&client->dev.kobj,
384 if (err) 369 &temp3_group)))
385 goto exit_remove_sysfs_thmc50; 370 goto exit_remove_sysfs_thmc50;
386 }
387 371
388 /* Register a new directory entry with module sensors */ 372 /* Register a new directory entry with module sensors */
389 data->hwmon_dev = hwmon_device_register(&client->dev); 373 data->hwmon_dev = hwmon_device_register(&client->dev);
@@ -399,6 +383,9 @@ exit_remove_sysfs:
399 sysfs_remove_group(&client->dev.kobj, &temp3_group); 383 sysfs_remove_group(&client->dev.kobj, &temp3_group);
400exit_remove_sysfs_thmc50: 384exit_remove_sysfs_thmc50:
401 sysfs_remove_group(&client->dev.kobj, &thmc50_group); 385 sysfs_remove_group(&client->dev.kobj, &thmc50_group);
386exit_free:
387 kfree(data);
388exit:
402 return err; 389 return err;
403} 390}
404 391
@@ -411,6 +398,8 @@ static int thmc50_remove(struct i2c_client *client)
411 if (data->has_temp3) 398 if (data->has_temp3)
412 sysfs_remove_group(&client->dev.kobj, &temp3_group); 399 sysfs_remove_group(&client->dev.kobj, &temp3_group);
413 400
401 kfree(data);
402
414 return 0; 403 return 0;
415} 404}
416 405
@@ -476,7 +465,18 @@ static struct thmc50_data *thmc50_update_device(struct device *dev)
476 return data; 465 return data;
477} 466}
478 467
479module_i2c_driver(thmc50_driver); 468static int __init sm_thmc50_init(void)
469{
470 return i2c_add_driver(&thmc50_driver);
471}
472
473static void __exit sm_thmc50_exit(void)
474{
475 i2c_del_driver(&thmc50_driver);
476}
480 477
481MODULE_AUTHOR("Krzysztof Helt <krzysztof.h1@wp.pl>"); 478MODULE_AUTHOR("Krzysztof Helt <krzysztof.h1@wp.pl>");
482MODULE_DESCRIPTION("THMC50 driver"); 479MODULE_DESCRIPTION("THMC50 driver");
480
481module_init(sm_thmc50_init);
482module_exit(sm_thmc50_exit);